[Home] [By Thread] [By Date] [Recent Entries]

  • From: pranav <pranav@i...>
  • To: xml-dev@l...
  • Date: Wed, 16 May 2001 15:27:40 +0530

Hi all,
         I am trying to displaying XML values into HTML my the help of following code. This code is working very fine with NS but not with IE.
 
Please help me to find out the reason and Solution of this problem.
 
Here is my code.........
 
<script language="javascript">
var xml; 
function init1()
{
 var x = xml.getElementsByTagName('rec');
 
 var dis = document.createElement('TABLE');
 
 for (i=0;i<x.length;i++)
 {
  var row = document.createElement('TR');
  for (j=0;j<x[i].childNodes.length;j++)
  {
   if (x[i].childNodes[j].nodeType != 1) continue;
   alert(x[i].childNodes[j].firstChild.nodeValue);
   var col = document.createElement('TD');
   var coltext = document.createTextNode(x[i].childNodes[j].firstChild.nodeValue);
   col.appendChild(coltext);
   row.appendChild(col);
  }
   dis.appendChild(row); 
 }
   document.getElementById('test').appendChild(dis);
}
//alert("hohohohoho");
function msXML()
{
  xml.validateOnParse = false;
  xml.resolveExternals = false;
  xml.onreadystatechange = CheckState;
  function CheckState()
  {
    if(xml.readyState == 4)
 {
  init1()
 }
  } 
}
function nsXML()
{
init1()
}
function init()
{
    if (document.implementation && document.implementation.createDocument)
 {
        xml = document.implementation.createDocument("", "", null);
  xml.addEventListener("load",nsXML,false);
 }
 else if (document.documentElement && document.documentElement.applyElement)
 {
 xml = new ActiveXObject("Microsoft.XMLDOM");
 msXML();
  }
 else
 {
 alert('Your browser can\'t handle this script');
 }  
 xml.load("x1.xml");        
}
</script>
<html>
<body >
<p>
God
</p>
<P ID="test">
</P>
<p>
great
</p>
</body>
</html>
 
Regards,
Pranav Kumar
Software Engineer
Informica India Pvt. Ltd.
Noida, UP, India
91-118-4514702,3
http://www.informica.com

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member