Get Element value with minidom with Python

前端 未结 9 2019
悲&欢浪女
悲&欢浪女 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:35

    It's a tree, and there may be nested elements. Try:

    def innerText(self, sep=''):
        t = ""
        for curNode in self.childNodes:
            if (curNode.nodeType == Node.TEXT_NODE):
                t += sep + curNode.nodeValue
            elif (curNode.nodeType == Node.ELEMENT_NODE):
                t += sep + curNode.innerText(sep=sep)
        return t
    

提交回复
热议问题