minidom get Element value

Scott F sdfATexpertuneDOTcom
Thu Mar 17 09:09:17 EST 2005


Hi all,

Today's embarassingly simple question goes like this.

I have a file, testdoc.xml, to parse.  
Inside the file is an element

        <refrain>Yo, Ho, Ho</refrain>

So, starting with

[code]

from xml.dom import minidom
xmldoc = minidom.parse('home\me\testdoc.xml')

[/code]

therefrain = getTagsByName('refrain')
print therefrain.toxml()

does print the whole Element

What code do I need to merely print the *value* of the element, i.e., 
I would like to see

        Yo, Ho, Ho

printed out.

I can get Attribute values, the whole Element with tags, etc., and 
could do a substring search on the Element, but surely something 
exists within minidom to do this.

Thanks.

Scott



More information about the Python-list mailing list