0

I have made a dialog which gets path of xml file and read content of xml file in a string. i have a variable called output which stires all contents of XML file. Now output is a string which contains all xml file contents. Now i want to parse this output

my code for parsing this is as follows:

output = e.target.result;
            console.log("file path"); 
            console.log(output);
            /*var xmlDoc=loadXMLDoc(output);
            console.log("XML DOC");
            console.log(xmlDoc);
            */
              myXML= document.all(output).XMLDocument
              console.log(myXML);

i am getting error of XMLDocument undefined. How should i parse this xmlstring?

Muneem Habib
  • 1,046
  • 4
  • 18
  • 49

1 Answers1

1

You can use xmlSerializer.

var xmlText = new XMLSerializer().serializeToString(xml);
var xmlTextNode = document.createTextNode(xmlText);
someDOMobject.appendChild(xmlTextNode);

More examples: Convert XML to String and append to page

Community
  • 1
  • 1
RealityDysfunction
  • 2,609
  • 3
  • 26
  • 53