Converting a Doc object into a string in python

Posted by Sam on Stack Overflow See other posts from Stack Overflow or by Sam
Published on 2010-03-31T01:09:46Z Indexed on 2010/03/31 1:13 UTC
Read the original article Hit count: 389

Filed under:
|

I'm using minidom to parse through an xml document. I took the data with yum tags and stored them in a list and calculated the frequency of the words. However, its not storing or reading them as strings in the list. Is there another way to do it? Right now this is what I have:

yumNodes = [node for node in doc.getElementsByTagName("yum")]

for node in yumNodes:
    yumlist.append(t.data for t in node.childNodes if t.nodeType == t.TEXT_NODE)

for ob in yumlist:
    for o in ob:
        if word not in freqDict:
            freqDict[word] = 1
        else:
            freqDict[word] += 1

© Stack Overflow or respective owner

Related posts about python

Related posts about minidom