简体   繁体   中英

How to parse xml recived as response text?

I am calling a webservice which is returning the xml data in encrypted format. I am receiving this as encrypted data as responseText. Now I want to parse this XML data. can you help me out

You can use DomParser which allows you to parse xml.

if (window.DOMParser)
{
  parser=new DOMParser();
  xmlDoc=parser.parseFromString(txt,"text/xml");
}
else // Internet Explorer
{
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async=false;
  xmlDoc.loadXML(txt); 
}

then

var tag = xmlDoc.getElementsByTagName("TagName");

However, before doing so, you will need to decrypt your response as you state in your question that the response is encrypted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM