Re: Convert raw data to XML



elrondrules@xxxxxxxxx wrote:

On Jan 30, 12:05 pm, John Nagle <n...@xxxxxxxxxxx> wrote:
elrondru...@xxxxxxxxx wrote:
On Jan 29, 8:54 pm, "Gabriel Genellina" <gagsl...@xxxxxxxxxxxx> wrote:

En Mon, 29 Jan 2007 23:42:07 -0300, <elrondru...@xxxxxxxxx> escribió:
the reason I wanted to write it as a file was to parse the file, look
for a specific attribute and execute a set of commands based on the
value of the attribute.. also i needed to display the output of the
http post in a more readable format..

That's straightforward. You confused people by asking the
wrong question. You wrote "Convert raw data to XML", but what
you want to do is parse XML and extract data from it.

This will do what you want:

http://www.crummy.com/software/BeautifulSoup/

For starters, try

from BeautifulSoup import BeautifulStoneSoup
xmlstring = somexml ## get your XML into here as one big
string
soup = BeautifulStoneSoup(xmlstring) # parse XML into tree
print soup.prettify() # print out in indented format

"soup" is a tree structure representing the XML, and there are
functions to easily find items in the tree by tag name, attribute,
and such. Work on the tree, not a file with the text of the indented
output.

John Nagle

is there any other way to do this without using BeautifulStoneSoup..
using existing minidom or ext..
i dont want to install anything new
yes, write it ;-)




.



Relevant Pages

  • Re: Convert raw data to XML
    ... you want to do is parse XML and extract data from it. ... "soup" is a tree structure representing the XML, ... is there any other way to do this without using BeautifulStoneSoup.. ...
    (comp.lang.python)
  • Re: XML editor using MFC
    ... add elements to the tree control. ... XML tree is represented by an HTREEITEM. ... except for the CDATA stuff which is a real pain to parse. ... Error recovery: simplest form, when you find an error, throw a CException-derived class, ...
    (microsoft.public.vc.mfc)
  • Re: Modeling Data for XML instead of SQL-DBMS
    ... It is a tree, ... A set of XML documents may include ... DBMS tools where the link specifications are metadata. ... but I don't think that is the hierarchy you ...
    (comp.databases.theory)
  • Re: TreeView Dynamic XML Binding
    ... Subject: TreeView Dynamic XML Binding ... Expand the ReturnHeader node. ... When I click on the tree node for the select ... I'm simply trying to display the xml element tree ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: TreeView with Recursive TreeNode....
    ... > head that he was trying to output a tree in html, ... The xml would possibly give you an advantage in already ... > "Mark Broadbent" wrote in message ... >> for mirroring this in a TreeView and this is probably correct. ...
    (microsoft.public.dotnet.framework.windowsforms)