Re: ElementTree : parse string input
- From: Fredrik Lundh <fredrik@xxxxxxxxxxxxxx>
- Date: Thu, 06 Jul 2006 16:49:19 +0200
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>
.
- References:
- ElementTree : parse string input
- From: rajarshi . guha
- ElementTree : parse string input
- Prev by Date: Re: setting variables from a tuple NEWB
- Next by Date: Re: searching for strings (in a tuple) in a string
- Previous by thread: ElementTree : parse string input
- Next by thread: Re: ElementTree : parse string input
- Index(es):
Relevant Pages
|