Re: ElementTree : parse string input



rajarshi.guha@xxxxxxxxx wrote:

Hi, recently having discovered ElementTree I'm stumped by a very simple
problem, which I can't find the answer to.

I have some XML in a string object. Now the parse() method of
ElementTree takes a filename or file-like object. So I tried creating a
StringIO object from the original string and then giving that to
parse(). But that does not seem to work.

that should work, but the fromstring function (and it's XML alias) is a lot easier to use.

data = "some xml in a string"

elem = ElementTree.XML(data)

also see the end of this section:

http://www.effbot.org/zone/element.htm#reading-and-writing-xml-files

</F>

.



Relevant Pages

  • ElementTree : parse string input
    ... I have some XML in a string object. ... Now the parse() method of ... ElementTree takes a filename or file-like object. ...
    (comp.lang.python)
  • Re: Working with XML
    ... If you manipulated data can end in a DataSet then ... Is there an easy object to use to handle XML? ... I know i can create a string object and simply create ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Working with XML
    ... If you have an EXISTING xml doc, then you need to use the XmlDocument, ... and find the correct place to insert/update data. ... I know i can create a string object and simply create ... I know there's a XMLDocument object but I ...
    (microsoft.public.dotnet.framework.aspnet)
  • Working with XML
    ... Basically, i am collecting a ton of info from SQL, from various Tables/Views/Procs, adding some data on the fly then I need to output the entire thing to XML. ... I know i can create a string object and simply create an XML string but that's messy. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Working with XML
    ... Is there an easy object to use to handle XML? ... Basically, i am collecting a ton of info from SQL, from various ... I know i can create a string object and simply create ...
    (microsoft.public.dotnet.framework.aspnet)