Parse XML from XMLHttpRequest

后端 未结 1 562
闹比i
闹比i 2021-01-22 06:42

I\'m using QML and XMLHttpRequest for fetching some XML-data.

  var doc = new XMLHttpRequest();
  if (doc.readyState == XMLHttpRequest.DONE) {
        var root =         


        
相关标签:
1条回答
  • 2021-01-22 07:28

    The text of an element node in the DOM is represented by a child element (a text node). The value of the text node is what you want.

    So change

    child.childNodes[j].nodeValue
    

    into

    child.childNodes[j].childNodes[0].nodeValue
    

    to make it work.

    See http://www.w3schools.com/dom/dom_nodes_get.asp

    Maybe also consider using a XmlListModel.

    0 讨论(0)
提交回复
热议问题