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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.