Jump to content

Parsing details from xml string.


palanikumark

Recommended Posts

Actually here i'm passing xml as string. If I pass as xml it works fine. It does not working if I pass xml as string i'm receiving error

Problem retrieving data
. What should I change to work fine. Here is my code.

 

var xmlString="<?xml version='1.0'?><note>  <to>Tove</to>  <from>Jani</from>  <heading>Reminder</heading>  <body>Dont forget me this weekend!</body> </note>";

# createXmlObject = function(xmlString) {  
# var xmlhttp;  
# xmlhttp=null;  
# if (window.XMLHttpRequest)  
#   {// code for Firefox, Opera, IE7, etc.  
# alert("safari");  
#   xmlhttp=new XMLHttpRequest();  
#   xmlhttp.overrideMimeType('text/xml');  
#   }  
# else if (window.ActiveXObject)  
#   {// code for IE6, IE5  
#   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  
#   }  
# if (xmlhttp!=null)  
#   {  
#     xmlhttp.onreadystatechange=stateChange;  
#   xmlhttp.open("GET",xmlString,true);  
#   xmlhttp.send(null);  
#     
#   }  
# else  
#   {  
#   alert("Your browser does not support XMLHTTP.");  
#   }  
# }  
#   
# function stateChange()  
# {  
# if (xmlhttp.readyState==4)  
#   {// 4 = "loaded"  
#   if (xmlhttp.status==200)  
#     {// 200 = "OK"  
#     document.getElementById('to').innerHTML=xmlhttp.status;
#     document.getElementById('from').innerHTML=xmlhttp.statusText;
#     document.getElementById('heading').innerHTML=xmlhttp.responseText;
#      }  
#   else  
#     {  
#     alert("Problem retrieving data:" + xmlhttp.statusText);  
#     }  
#   }  
# }     

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/155155-parsing-details-from-xml-string/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.