I'm running into some trouble with the DOMParser. I'm using intelliJ IDE and writing in Typescript.
Here is my code:
public domparser = new DOMParser();
this.domdoc = this.domparser.parseFromString(this.xmlDoc, 'text/xml');
console.log("domdoc: " + this.domdoc);
I'm seeing
domdoc: [object XMLDocument]
in my console.
Any suggestions on how to print the XML document, rather than just '[object XMLDocument]'?
Thank you.
You can use the querySelector and the wildcard *
to select all the xml element.
public domparser = new DOMParser();
this.domdoc = this.domparser.parseFromString(this.xmlDoc, 'text/xml');
let elements = this.domdoc.querySelectorAll("*");
for (element of elements){
console.log(element.innerHTML);
}