Quantcast
Channel: Qt DevNet forums: Qt WebKit
Viewing all articles
Browse latest Browse all 542

Getting XML document from server and extracting strings from it

$
0
0
Good day fellow programmers, I am trying to communicate with a rest API web service, get a xml document and then parse it’s values into strings. Since I am new to this topic any help would be greatly appreciated! This is what I built using the XMLHTTPREQUEST example: import QtQuick 2.0   Rectangle  {     width: 350; height: 400       function showRequestInfo(text)  {         log.text = log.text + "\n" + text         console.log(text)     }       Text  { id: log; anchors.fill: parent; anchors.margins: 10 }       Rectangle  {         id: button         anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom; anchors.margins: 10         width: buttonText.width + 10; height: buttonText.height + 10         border.width: mouseArea.pressed ? 2 : 1         radius : 5; smooth: true           Text  { id: buttonText; anchors.centerIn: parent; text: "Request" }           MouseArea  {             id: mouseArea             anchors.fill: parent             onClicked:  {                 log.text = ""                 console.log("\n")                   var doc = new XMLHttpRequest();                 doc.onreadystatechange = function()  {                                     if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED)  {                                         } else if (doc.readyState == XMLHttpRequest.DONE)  {                                       var a = doc.responseXML.documentElement;                                       for (var ii = 0; ii < a.childNodes.length; ++ii)  {                                       showRequestInfo(a.childNodes[ii].nodeName);                                                          }                            }                         }                     doc.open("POST", 'http://www.example.com/mydata.xml');                 doc.send();             }         }     } } This code does successfully communicate with the server and retrieves information from it. The problem is that it only names the node’s name but leaves the values out. Example response: is-admin #text signature #text restrictions #text How can I fix this and manage to save the information retrieved with the xml document into strings? Thanks a LOT in advance!

Viewing all articles
Browse latest Browse all 542

Trending Articles


Practice Sheet of Right form of verbs for HSC Students


Rajasthan Board 10th Result 2016 Roll No wise & Name Wise


Moondru Mudichu 20-07-2016 – Polimer tv Serial


fs_older_downloads


Calaveras conflict results in shooting, 4 arrests


Guilty Pleasures


Black Angus Grilled Artichokes


Download: Rich Bizzy -Panono Ukwenda (Cover)


Muloraki Au


where in jaunpur randi khana