By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,222 Members | 2,478 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,222 IT Pros & Developers. It's quick & easy.

minidom get Element value

P: n/a
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. from xml.dom import minidom
  3. xmldoc = minidom.parse('home\me\testdoc.xml')
  4.  
  5.  
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
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.