get element text in DOM?

Juliano Freitas jubafre at atlas.ucpel.tche.br
Wed Nov 10 14:11:09 EST 2004


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





More information about the Python-list mailing list