Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XML loading (Internet Explorer & Firefox)

    Arg, this works perfectly in Firefox, but in Internet Explorer it errors out as "Object Required" in this line:
    Code:
    build = x[0].childNodes[3].childNodes[1].childNodes[1].firstChild.nodeValue;
    Code:
    <script>
    function importXML()
    {
    	if (document.implementation && document.implementation.createDocument)
    	{
    		xmlDoc = document.implementation.createDocument("", "", null);
    		xmlDoc.onload = getBuild;
    	}
    	else if (window.ActiveXObject)
    	{
    		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    		xmlDoc.onreadystatechange = function () {
    			if (xmlDoc.readyState == 4) getBuild()
    		};
     	}
    	else
    	{
    		alert('Your browser can\'t handle this script');
    		return;
    	}
    	xmlDoc.load("/SystemService/getSystemInfo");
    }
    function getBuild()
    {
    	var x = xmlDoc.getElementsByTagName('Something');
      
      build = x[0].childNodes[3].childNodes[1].childNodes[1].firstChild.nodeValue;
      build = build.slice(6, 10);
      var newEl = document.createTextNode(build);
    	document.getElementById('build').appendChild(newEl);
      
      var x = xmlDoc.getElementsByTagName('SomethingElse');
      
      hostname = x[0].childNodes[3].firstChild.nodeValue;
      var newEl = document.createTextNode(hostname);
    	document.getElementById('hostname').appendChild(newEl);
    }
    </script>
    Can someone help me figure out whats going wrong here? Thanks!

  • #2
    New Coder
    Join Date
    Nov 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
    xmlDoc.async="false"
    xmlDoc.load("note.xml")
    
    nodes=xmlDoc.documentElement.childNodes
    a1.innerText=nodes.item(0).text
    a2.innerText=nodes.item(1).text
    a3.innerText=nodes.item(2).text
    a4.innerText=nodes.item(3).text
    http://www.w3schools.com/xml/tryit.asp?filename=note
    this works for IE, but not Firefox!

  • #3
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There are a couple working examples archived here... (search this & the xml forum); and about the error, you can narrow it down by checking for 'typeof', starting with the object and tacking on each reference, until you get undefined, or something.
    *this message will self destruct in n-seconds*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •