New test try this one, the same issue but with NodeType and nodeValue:
<HTML>
<head>
<script>
var doc;
function test(){
doc = document.implementation.createDocument("", "", null);
doc.onload = function(e){
// alert(doc.firstChild.getAttribute("id")); //<--HERE
var idArray = new Array();
var siteNodes = doc.getElementsByTagName("site");
if(siteNodes.length < 1)
{
// debug('getSiteIdList() - No site nodes found');
return false;
}
for(var i=0; i< siteNodes.length; ++i)
{
// Netscape/Mozilla will return whitespace as a node so check that
it is a valid node with children
if(siteNodes[i].nodeType != 1)
continue;
// Search directly for siteId tag, will return array of nodes, use
element 0 since only one child of that
// node will qualify. Use node value of first child since text
inside is considered child node.
var siteIdNodes = siteNodes[i].getElementsByTagName("siteId");
if(siteIdNodes && siteIdNodes[0].hasChildNodes())
idArray.push(siteIdNodes[0].firstChild.nodeValue);
// debug('getSiteIdList: found ' +
siteIdNodes[0].firstChild.nodeValue);
}
return idArray;
};
doc.load("test.xml");
}
</script>
</head>
<body onload="test()">
test
</body>
</HTML>
test.xml
<?xml version="1.0" encoding="UTF-8"?>
<sites>
<site>
<siteId>site_4803b90d7deea</siteId>
<publishDirectory></publishDirectory>
<designId>366</designId>
<tint>default</tint>
<title></title>
<tagline></tagline>
<lastPublished>04/14/2008 21:11:59 GMT</lastPublished>
<rssFeed></rssFeed><atomFeed></
atomFeed><lastModifiedTime>1213191015</
lastModifiedTime><lastModified>06/11/2008 13:30:15 GMT</lastModified></
site>
<site><siteId>site_485bb4acbd7e1</siteId><publishDirectory></
publishDirectory><designId>33</designId><tint>default</tint><title>My
New Website</title><tagline>
mgritsay.hostopia.com</
tagline><lastPublished></lastPublished><lastModifiedTime>1213969580</
lastModifiedTime><lastModified>06/20/2008 13:46:20 GMT</lastModified></
site><site><siteId>site_485bb4b387bfd</siteId><publishDirectory></
publishDirectory><designId>33</designId><tint>default</tint><title>My
New Website</title><tagline>
mgritsay.hostopia.com</
tagline><lastPublished></lastPublished><lastModifiedTime>1213969587</
lastModifiedTime><lastModified>06/20/2008 13:46:27 GMT</lastModified></
site></sites>