We help IT Professionals succeed at work.

Parsing XML in IE and Firefox

swedesamurai
swedesamurai asked
on
Medium Priority
875 Views
Last Modified: 2012-05-07
Hi Experts,
Here is what I think is a simple question but I can't seem to figure it out.
I want to parse a really simple xml file known as test.xml and display the fields in a span on my browser page it works great in Firefox but returns blank in Internet Explorer 8.
I would appeciate it if you can find out what it is that is blocking this thing from displaying the parsed fields.
Here is the simple xml File:
<?xml version="1.0" encoding="utf-8"?>	
<rss version="2.0">
<channel>
<line01> </line01>
<line02>'Ciih½VÓœ</line02>
<line03> </line03>
<line04>2009t313÷</line04>
<line05> </line05>
<line06> </line06>
<line07>xÐpW:</line07>
<line08>12-24-26-36-42</line08>
<line09> </line09>
<line10> </line10>
<line11>xÐ:</line11>
<line12>1-4</line12>
<line13> </line13>
<line14> </line14>
<line15>xÐ:</line15>
<line16>1-4</line16>
<line17> </line17>
<line18> </line18>
<line19>
!„'V:</line19>
<line20>16.009.560,30 ¬</line20>
<line21> </line21>
<line22> </line22>
<line23>¨Â ½V†?</line23>
<line24>'2'„ih½V!</line24>
<line25> </line25>
<line26> </line26>
<line27>!V</line27>
<line28>2009t320÷</line28>
<line29> </line29>
<line30> </line30>
<line31>!„'V:</line31>
<line32>29,000,000 Euros!</line32>
<line33> </line33>
</channel>
</rss>
 
Here is the Header Javascript:
<script type="text/javascript">
function loadXMLDoc(dname) 
{
var xmlDoc;
if (window.XMLHttpRequest)
  {
  xmlDoc=new window.XMLHttpRequest();
  xmlDoc.open("GET",dname,false);
  xmlDoc.send("");
  return xmlDoc.responseXML;
  }
// IE 5 and IE 6
else if (ActiveXObject("Microsoft.XMLDOM"))
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async=false;
  xmlDoc.load(dname);
  return xmlDoc;
  }
alert("Error loading document");
return null;
}
</script>
 
Here sre the HTML Fields and the inline Javascript:
 
            <div style="font-size:11px; text-align:center; font-weight: bold; width: 160px;">
            <p><span id="line01"></span><br />
            <span id="line02"></span><br />
            <span id="line03"></span><br />
            <span id="line04"></span><br />
            <span id="line05"></span><br />
            <span id="line06"></span><br />
            <span id="line07"></span><br />
            <span id="line08"></span><br />
            <span id="line09"></span><br />
            <span id="line10"></span><br />
            <span id="line11"></span><br />
            <span id="line12"></span><br />
            <span id="line13"></span><br />
            <span id="line14"></span><br />
            <span id="line15"></span><br />
            <span id="line16"></span><br />
            <span id="line17"></span><br />
            <span id="line18"></span><br />
            <span id="line19"></span><br />
            <span id="line20"></span><br />
            <span id="line21"></span><br />
            <span id="line22"></span><br />
            <span id="line23"></span><br />
            <span id="line24"></span><br />
            <span id="line25"></span><br />
            <span id="line26"></span><br />
            <span id="line27"></span><br />
            <span id="line28"></span><br />
            <span id="line29"></span><br />
            <span id="line30"></span><br />
            <span id="line31"></span><br />
            <span id="line32"></span><br />
            <span id="line33"></span></p>
           
            <script type="text/javascript">
				xmlDoc=loadXMLDoc("feeds/test.xml");
				document.getElementById("line01").innerHTML=xmlDoc.getElementsByTagName("line01")[0].childNodes[0].nodeValue;
				document.getElementById("line02").innerHTML=xmlDoc.getElementsByTagName("line02")[0].childNodes[0].nodeValue;
				document.getElementById("line03").innerHTML=xmlDoc.getElementsByTagName("line03")[0].childNodes[0].nodeValue;
				document.getElementById("line04").innerHTML=xmlDoc.getElementsByTagName("line04")[0].childNodes[0].nodeValue;
				document.getElementById("line05").innerHTML=xmlDoc.getElementsByTagName("line05")[0].childNodes[0].nodeValue;
				document.getElementById("line06").innerHTML=xmlDoc.getElementsByTagName("line06")[0].childNodes[0].nodeValue;
				document.getElementById("line07").innerHTML=xmlDoc.getElementsByTagName("line07")[0].childNodes[0].nodeValue;
				document.getElementById("line08").innerHTML=xmlDoc.getElementsByTagName("line08")[0].childNodes[0].nodeValue;
				document.getElementById("line09").innerHTML=xmlDoc.getElementsByTagName("line09")[0].childNodes[0].nodeValue;
				document.getElementById("line10").innerHTML=xmlDoc.getElementsByTagName("line10")[0].childNodes[0].nodeValue;
				document.getElementById("line11").innerHTML=xmlDoc.getElementsByTagName("line11")[0].childNodes[0].nodeValue;
				document.getElementById("line12").innerHTML=xmlDoc.getElementsByTagName("line12")[0].childNodes[0].nodeValue;
				document.getElementById("line13").innerHTML=xmlDoc.getElementsByTagName("line13")[0].childNodes[0].nodeValue;
				document.getElementById("line14").innerHTML=xmlDoc.getElementsByTagName("line14")[0].childNodes[0].nodeValue;
				document.getElementById("line15").innerHTML=xmlDoc.getElementsByTagName("line15")[0].childNodes[0].nodeValue;
				document.getElementById("line16").innerHTML=xmlDoc.getElementsByTagName("line16")[0].childNodes[0].nodeValue;
				document.getElementById("line17").innerHTML=xmlDoc.getElementsByTagName("line17")[0].childNodes[0].nodeValue;
				document.getElementById("line18").innerHTML=xmlDoc.getElementsByTagName("line18")[0].childNodes[0].nodeValue;
				document.getElementById("line19").innerHTML=xmlDoc.getElementsByTagName("line19")[0].childNodes[0].nodeValue;
				document.getElementById("line20").innerHTML=xmlDoc.getElementsByTagName("line20")[0].childNodes[0].nodeValue;
				document.getElementById("line21").innerHTML=xmlDoc.getElementsByTagName("line21")[0].childNodes[0].nodeValue;
				document.getElementById("line22").innerHTML=xmlDoc.getElementsByTagName("line22")[0].childNodes[0].nodeValue;
				document.getElementById("line23").innerHTML=xmlDoc.getElementsByTagName("line23")[0].childNodes[0].nodeValue;
				document.getElementById("line24").innerHTML=xmlDoc.getElementsByTagName("line24")[0].childNodes[0].nodeValue;
				document.getElementById("line25").innerHTML=xmlDoc.getElementsByTagName("line25")[0].childNodes[0].nodeValue;
				document.getElementById("line26").innerHTML=xmlDoc.getElementsByTagName("line26")[0].childNodes[0].nodeValue;
				document.getElementById("line27").innerHTML=xmlDoc.getElementsByTagName("line27")[0].childNodes[0].nodeValue;
				document.getElementById("line28").innerHTML=xmlDoc.getElementsByTagName("line28")[0].childNodes[0].nodeValue;
				document.getElementById("line29").innerHTML=xmlDoc.getElementsByTagName("line29")[0].childNodes[0].nodeValue;
				document.getElementById("line30").innerHTML=xmlDoc.getElementsByTagName("line20")[0].childNodes[0].nodeValue;
				document.getElementById("line31").innerHTML=xmlDoc.getElementsByTagName("line31")[0].childNodes[0].nodeValue;
				document.getElementById("line32").innerHTML=xmlDoc.getElementsByTagName("line32")[0].childNodes[0].nodeValue;
				document.getElementById("line33").innerHTML=xmlDoc.getElementsByTagName("line33")[0].childNodes[0].nodeValue;
				
			</script> 
</div>

Open in new window

Comment
Watch Question

Commented:
Fastest, safest way is jquery!
www.jquery.com

http://think2loud.com/reading-xml-with-jquery/

I'll make a code for you when I get to work in an hour
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.