Jump to content

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

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
gruntmonk

gruntmonk

    Newbie

  • Members
  • Pip
  • 5 posts
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

#2
Taar

Taar

    Newbie

  • Members
  • Pip
  • 1 posts
Hello!

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

AJAX XML

Hope this helps!

cheers,
Taar