3 Replies - 547 Views - Last Post: 05 February 2013 - 06:45 PM

#1 knightmare2dream  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 13-February 10

XML is empty in IE and FF not Chrome

Posted 02 February 2013 - 03:53 PM

I am opening simple xml data file to populate a page, works great in chrome but in ff and IE the xml variable appears to be empty. Using Firebug I see the response to the get statement shows the xml so it appears I'm doing something wrong trying to get the response data into my inputs.

Anyone know what I'm doing wrong for getting this data for FF and IE?


xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","ticketData.xml",false);
xmlhttp.send();
var xmlDoc=xmlhttp.responseXML;
var emps = xmlDoc.getElementsByTagName("employee");
var startTickets = xmlDoc.getElementsByTagName("start");
var assignTick = xmlDoc.getElementsByTagName("assigned");
var reopenTick = xmlDoc.getElementsByTagName("reopened");
var handoffTick = xmlDoc.getElementsByTagName("handoff");
var endTick = xmlDoc.getElementsByTagName("end");


alert(xmlDoc.documentElement.getElementsByTagName('EmpTickets').length);
	for(var x=0;x < emps.length;x++)
	{
		alert("inside");
		var empNum = "emp" + x;
		document.getElementById(empNum).innerHTML=
		emps[x].childNodes[0].nodeValue;
	}



XML

<?xml version="1.1" ?>
<EmpTickets>
<employee>mfizhug</employee>
<start>1</start>
<reopened>1</reopened>
<assigned>1</assigned>
<handoff>1</handoff>
<end>1</end>
<employee>tayon</employee>
<start>1</start>
<reopened>1</reopened>
<assigned>1</assigned>
<handoff>1</handoff>
<end>1</end>
<employee>vaughnf</employee>
<start>1</start>
<reopened>1</reopened>
<assigned>1</assigned>
<handoff>1</handoff>
<end>1</end>
<employee>tarmijo</employee>
<start>1</start>
<reopened>1</reopened>
<assigned>1</assigned>
<handoff>1</handoff>
<end>1</end>
<employee>mthrelfa</employee>
<start>1</start>
<reopened>1</reopened>
<assigned>1</assigned>
<handoff>1</handoff>
<end>1</end>
<employee>beebe</employee>
<start>1</start>
<reopened>1</reopened>
<assigned>1</assigned>
<handoff>1</handoff>
<end>1</end>
<employee>fkwok</employee>
<start>1</start>
<reopened>1</reopened>
<assigned>1</assigned>
<handoff>1</handoff>
<end>1</end>
<employee>jkbowers</employee>
<start>1</start>
<reopened>1</reopened>
<assigned>1</assigned>
<handoff>1</handoff>
<end>1</end>
<employee>cblount</employee>
<start>1</start>
<reopened>1</reopened>
<assigned>1</assigned>
<handoff>1</handoff>
<end>1</end>
<employee>jamendez</employee>
<start>1</start>
<reopened>1</reopened>
<assigned>1</assigned>
<handoff>1</handoff>
<end>1</end>
<employee>jcronk</employee>
<start>1</start>
<reopened>1</reopened>
<assigned>1</assigned>
<handoff>1</handoff>
<end>1</end>
<employee>avthomse</employee>
<start>1</start>
<reopened>1</reopened>
<assigned>1</assigned>
<handoff>1</handoff>
<end>1</end>
<kicked>1</kicked>
</EmpTickets>


This post has been edited by knightmare2dream: 02 February 2013 - 05:16 PM


Is This A Good Question/Topic? 0
  • +

Replies To: XML is empty in IE and FF not Chrome

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3317
  • View blog
  • Posts: 11,217
  • Joined: 12-December 12

Re: XML is empty in IE and FF not Chrome

Posted 02 February 2013 - 05:02 PM

Can you post a sample of the XML document? Perhaps it is malformed in some way.

Try also with:

var emps = xmlDoc.documentElement.getElementsByTagName("employee");

and alert or console.log emps[x].hasChildNodes() within the loop.

This post has been edited by andrewsw: 02 February 2013 - 05:03 PM

Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6048
  • View blog
  • Posts: 23,473
  • Joined: 23-August 08

Re: XML is empty in IE and FF not Chrome

Posted 02 February 2013 - 06:58 PM

That's just a badly designed XML document, IME.

Should be something like

<?xml version="1.1" ?>
<EmpTickets>
  <employee>
    <name>mfizhug</name>
    <start>1</start>
    <reopened>1</reopened>
    <assigned>1</assigned>
    <handoff>1</handoff>
    <end>1</end>
  </employee>
</EmpTickets>


Also, XML version 1.1? That might be a problem as well.
Was This Post Helpful? 0
  • +
  • -

#4 knightmare2dream  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 13-February 10

Re: XML is empty in IE and FF not Chrome

Posted 05 February 2013 - 06:45 PM

So after banging my head forever and trying your suggestions I found it was the xml encoding and version.

 <?xml version="1.0" encoding="UTF-8" standalone="no" ?> 


tiger woods fist pump*
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1