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?

2

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

How are you passing the xml, is it a valid xml? Test with a basic one first.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.