get element text in DOM?

Jeremy Jones zanesdad at bellsouth.net
Wed Nov 10 14:19:26 EST 2004


Juliano Freitas wrote:

>How can i get the text between the <teste> tags??
>
>  
>
>>>>xml = """<root><teste> texto </teste></root>"""
>>>>from xml.dom import minidom
>>>>document = minidom.parseString(xml)
>>>>document
>>>>        
>>>>
><xml.dom.minidom.Document instance at 0x4181df0c>
>  
>
>>>>minidom.getElementsByTagName('teste')
>>>>        
>>>>
>
>  
>
>>>>element = document.getElementsByTagName('teste')
>>>>element
>>>>        
>>>>
>[<DOM Element: teste at 0x418e110c>]
>  
>
>>>>element[0].nodeType
>>>>        
>>>>
>1
>
>Juliano Freitas
>
>
>  
>
How about something like this:



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20041110/fd8ea2a0/attachment.html>


More information about the Python-list mailing list