serumx
01-21-2008, 10:02 AM
Hi!
I've got the following XML document:
<Lokalitet>
<Lok>1</Lok>
<Rapporter>
<Name>Multi 2003
<Link>http://22fj.sdfh.jk</Link>
</Name>
<Name>Multi 2004
<Link>http://jkhkj.sdfh.jk</Link>
</Name>
</Rapporter>
</Lokalitet>
<Lokalitet>
<Lok>2</Lok>
<Rapporter>
<Name>Multi 2000
<Link>http://33fj.sdfh.jk</Link>
</Name>
</Rapporter>
</Lokalitet>
As you can see there's two childs named "Name" in the first section and one in the second.
Here's the code:
var y=xmlDoc.getElementsByTagName('Lok')
var r=xmlObj.getElementsByTagName('Name')
for (i=0;i<y.length;i++)
{
document.write(xmlObj.childNodes(0).childNodes(1).tagName)
document.write("<br />")
for (j=0;j<r.length;j++)
{
if (r[j].hasChildNodes()) {
document.write(xmlObj.childNodes[i].childNodes(2).childNodes[j].childNodes(0).text)
document.write("<br />")
} //if
} //for
}//end for
The problem is:
The output is only from the first section of the XML document (Lok 1). The rest of the XML document is obviously not prossessed.
Does anyone have a solution to this problem?
I've got the following XML document:
<Lokalitet>
<Lok>1</Lok>
<Rapporter>
<Name>Multi 2003
<Link>http://22fj.sdfh.jk</Link>
</Name>
<Name>Multi 2004
<Link>http://jkhkj.sdfh.jk</Link>
</Name>
</Rapporter>
</Lokalitet>
<Lokalitet>
<Lok>2</Lok>
<Rapporter>
<Name>Multi 2000
<Link>http://33fj.sdfh.jk</Link>
</Name>
</Rapporter>
</Lokalitet>
As you can see there's two childs named "Name" in the first section and one in the second.
Here's the code:
var y=xmlDoc.getElementsByTagName('Lok')
var r=xmlObj.getElementsByTagName('Name')
for (i=0;i<y.length;i++)
{
document.write(xmlObj.childNodes(0).childNodes(1).tagName)
document.write("<br />")
for (j=0;j<r.length;j++)
{
if (r[j].hasChildNodes()) {
document.write(xmlObj.childNodes[i].childNodes(2).childNodes[j].childNodes(0).text)
document.write("<br />")
} //if
} //for
}//end for
The problem is:
The output is only from the first section of the XML document (Lok 1). The rest of the XML document is obviously not prossessed.
Does anyone have a solution to this problem?