I'm sure it's not mozilla's fault but I'm at a loss here.
I'm loading the following XML data into a page using
http_request:
<?xml version="1.0" encoding="iso-8859-1"?>
<forum>
<message id="msg1">
<date>10/13/2005</date>
<time>10:39 pm</time>
<name>Josh</name>
<comment>This is a message.</comment>
</message>
<message id="msg2">
<date>10/14/2005</date>
<time>11:00 pm</time>
<name>Jeff</name>
<comment>This is another message.</comment>
</message>
<message id="msg3">
<date>10/21/2005</date>
<time>3:21 pm</time>
<name>Jeff</name>
<comment>This is yet another message.</comment>
</message>
</forum>
The following functions retrieve the data and displays it on
the page:
function getmessages() {
var xmldoc = http_request.responseXML;
var
numberofmessages=xmldoc.getElementsByTagName('mess age').length
;
var root_node = xmldoc.getElementsByTagName('message');
for( var x = 0; x < numberofmessages; x++ ) {
var message =
root_node[x].childNodes[3].firstChild.nodeValue;
insertcontent(message);
var messagedatetime =
root_node[x].childNodes[2].firstChild.nodeValue + " [" +
root_node[x].childNodes[0].nodeName + ": " +
root_node[x].childNodes[0].firstChild.nodeValue + " -- " +
root_node[x].childNodes[1].nodeName + ": " +
root_node[x].childNodes[1].firstChild.nodeValue + "]" ;
insertcontent(messagedatetime);
}
insertcontent(numberofmessages);
}
function insertcontent(words) {
var ourDiv=document.getElementById('chatbox');
var ptag=document.createElement('p'); // create p tag
var chattext=document.createTextNode(words);// - create
the text to go in p tag
ptag.appendChild(chattext); // put text in p tag
ourDiv.appendChild(ptag); //put p tag in div
}
IE displays the results correctly:
This is a message.
Josh [date: 10/13/2005 -- time: 10:39 pm]
This is another message.
Jeff [date: 10/14/2005 -- time: 11:00 pm]
This is yet another message.
Jeff [date: 10/21/2005 -- time: 3:21 pm]
3
But Mozilla only shows:
10:39 pm
Any clues?????