Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Problem: XML, javascript e4x and trying to display the whole XML output

xml innerHTML

  • Please log in to reply
1 reply to this topic

#1 gruntmonk

gruntmonk

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 21 July 2010 - 12:15 AM

I have a service which churns out raw XML.
I have a javascript page with e4x enabled.
I am trying to get all the XML displayed into a div object.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>My Data</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<script type="text/javascript">
function getInfo()
{ 
	
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
   
   xhr.open("POST", "http://mysite:4321/select/?p=1&q=2", true);
 

  
    xhr.onreadystatechange  = function()
    { 
    	
         if(xhr.readyState  == 4)
         {
         	document.getElementById("ajax").innerHTML.value = xhr.responseText;
         	
			
         }          
    }
 
	xhr.send(null);    
   
} 
</script>
</head>
                 
<body onLoad="getInfo();">
<div id="ajax">
</div>
</body>

</html>


I have tried e4x, but I'm still unsure how it works! i.e.
I have to add ";e4x" to the language type, but it seems to have issues with the declaration of getInfo.

I have googled around and can't seem to find anything which allows you to display the whole XML (only transfer data from specific elements).

Either, how do I get all the XML displayed on my page (in text format) in javascript (old style)?
Or, How do I do it in e4x? Is e4x worth embracing?

Ay guidance would be much appreciated.

Regards,

Gruntmonk
  • 0

#2 Taar

Taar

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 21 July 2010 - 05:48 AM

Hello!

I did some searching myself and came up with this link from w3schools.

AJAX XML

Hope this helps!

cheers,
Taar
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download