Get Element value with minidom with Python

前端 未结 9 1979
悲&欢浪女
悲&欢浪女 2020-11-29 18:01

I am creating a GUI frontend for the Eve Online API in Python.

I have successfully pulled the XML data from their server.

I am trying to grab the value from

相关标签:
9条回答
  • 2020-11-29 18:43

    I had a similar case, what worked for me was:

    name.firstChild.childNodes[0].data

    XML is supposed to be simple and it really is and I don't know why python's minidom did it so complicated... but it's how it's made

    0 讨论(0)
  • 2020-11-29 18:47

    you can use something like this.It worked out for me

    doc = parse('C:\\eve.xml')
    my_node_list = doc.getElementsByTagName("name")
    my_n_node = my_node_list[0]
    my_child = my_n_node.firstChild
    my_text = my_child.data 
    print my_text
    
    0 讨论(0)
  • 2020-11-29 18:48

    It should just be

    name[0].firstChild.nodeValue
    
    0 讨论(0)
提交回复
热议问题