Level 47
http://goessner.net/download/prj/jsonxml/
Don't nessesary need to convert to Json, but use the example to read the xml.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I am using VUE resource to read xml file . I have the following code ready.
methods: {
getNewTitle () {
this.$http.get('data/books.xml').then((response) => {
console.log(response.body);
this.getBookName(response.body);
})
},
getBookName (xmlDoc) {
var x, i, txt;
console.log(xmlDoc);
// xmlDoc = xml.responseXML;
txt = "";
x = xmlDoc.documentElement.childNodes;
for (i = 0; i < x.length; i++) {
if (x[i].nodeType == 1) {
txt += x[i].nodeName + "<br>";
}
}
return txt;
}
}
However, the xml is treated as a string and not as an xml and consequently in fails in the getBookName method whenever I try to do
x = xmlDoc.documentElement.childNodes;
Can you please help me out with this?
Thanks and Regards Gagan
http://goessner.net/download/prj/jsonxml/
Don't nessesary need to convert to Json, but use the example to read the xml.
Please or to participate in this conversation.