Reading XML using Python minidom and iterating over each node

后端 未结 5 1640
既然无缘
既然无缘 2020-12-08 10:38

I have an XML structure that looks like the following, but on a much larger scale:


    
        
             


        
5条回答
  •  悲&欢浪女
    2020-12-08 11:08

    I played around with it a bit, and here's what I got to work:

    # ...
    authortext= a.childNodes[0].nodeValue
    print authortext
    

    leading to output of:

    C:\temp\py>xml2.py
    1
    Bob
    Nigel
    2
    Alice
    Mary
    

    I can't tell you exactly why you have to access the childNode to get the inner text, but at least that's what you were looking for.

提交回复
热议问题