[Tutor] How to get a string from a DOM Text node ?

Alan Gauld alan.gauld at btinternet.com
Mon May 26 00:10:19 CEST 2008


"Zameer Manji" <zmanji at gmail.com> wrote in
>
> I'm trying to extract some information from the following xml file:
> http://pastebin.ca/1029125
>
> This is the code that I have so far:
>
> import xml.dom.minidom

> This code prints out the following:
>
> <DOM Element: key at 0xbafb98>
> <key>42</key>
> <DOM Text node "
>                ">
>
> The problem is that the Text node that is printed out is blank, when 
> it
> should be 42. What do I need to do so I can get tdict.childNodes[2] 
> to

I may be off base here; I only used DOM once. I usually use
ElementTree for parsing XML(and only rarely do that!). But isn't there
a data or content field on the tag object that you have to use?

Just a vague memory and too late/lazy to look it up!

It might be a clue till somebody who really knows minidom replies!

Alan G. 




More information about the Tutor mailing list