0

This is running in IE browser.

This is my xml

<fields>

                <from><type>string</type><value> India</value></from>

                <number><type>string</type><value>1231</value></number>

                <aDate><type>string</type><value>2022-04-12</value></aDate>          

</fields>

Trying to parse this xml and fetch the values

Excpected result is

India1231

2022-04-12

if (window.DOMParser){

  parser=new DOMParser();

  xmlDoc=parser.parseFromString(xml,"text/xml");

} else // Internet Explorer {

  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");

  xmlDoc.async=false;

  xmlDoc.loadXML(xml);

  var fieldLen = xmlDoc.getElementsByTagName("fields").length;

  var from= xmlDoc.getElementsByTagName("from").childNodes[1].nodeValue; // line 9

  var number= xmlDoc.getElementsByTagName("number").childNodes[0].nodeValue;

  var aDate= xmlDoc.getElementsByTagName("aDate").childNodes[0].nodeValue;

}

This gives parsing error at line no 9

2
  • IE7 is ancient. IE8 is over a decade old. Why on earth are you trying to support it in 2022? Commented Apr 12, 2022 at 10:30
  • ya I know, but that is my requirement. Its an old system. Commented Apr 12, 2022 at 10:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.