[Tutor] how to get the content of an XML elements.
Kent Johnson
kent37 at tds.net
Wed Apr 5 14:28:53 CEST 2006
Keo Sophon wrote:
> On Sunday 02 April 2006 04:47, Kent Johnson wrote:
>> Alan Gauld wrote:
>>> "Keo Sophon" <keosophon at khmeros.info> wrote in message
>>> news:200603311906.26110.keosophon at khmeros.info...
>>>
>>>> Is there anyway to get the content of an XML elements. I am using
>>>> xml.dom.
>>> For true XML I think ElemTree (by Fred Lundh?) is the best approach.
>>> Try a Google search.
>> Yes, it's ElementTree though.
>>
>> Keo, what do you mean, "get the content of an XML elements"?
>>
>> Kent
>
> for example:
>
> .....
> <to>someone at email.com</to>
> .....
>
> I would like to get "someone at email.com" of <to>.
With ElementTree it would be something like
doc = ElementTree.parse('file.xml')
to = doc.find('//to')
print to.text
Kent
More information about the Tutor
mailing list