hi, i think im missing something here....
i have some xml stored in javascript:
<picture>
<date>5-5-2007</date>
<title>Pictur e title</title>
<filename>filen ame.jpg</filename>
<size>6x4</size>
</picture>
i have stored "picture"
all i then want to do, is list the childnode names and each of their values, this is what ive done so far:
It shows the node names but Ive tried all sorts of combinations of syntax for the second line but cant get it to show the value.
Also tried:
but that didnt work either. I know i could getElementByTag Name() for each child node, but some "picture" nodes have a different number of childnodes so wanted to do it automatically.
Anybody see where i am going wrong?
thanks!
Andy
i have some xml stored in javascript:
<picture>
<date>5-5-2007</date>
<title>Pictur e title</title>
<filename>filen ame.jpg</filename>
<size>6x4</size>
</picture>
i have stored "picture"
Code:
var XMLinfo = xmlDoc.getElementsByTagName('picture');
Code:
var n = XMLinfo.childNodes.length;
var output = "";
for (i=0;i<n;i++)
{
if (infoName != "#text" && infoName != "")
{
output += XMLinfo.childNodes[i].nodeName;
output += ": ";
//this is the line with the problem
output += XMLinfo.childNodes.item(i).nodeValue;
}
}
alert(output);
It shows the node names but Ive tried all sorts of combinations of syntax for the second line but cant get it to show the value.
Also tried:
Code:
infoName = XMLinfo.childNodes[i].nodeName; XMLinfo.getElementsByTagName(infoName)[0].childNodes[0].nodeValue
Anybody see where i am going wrong?
thanks!
Andy
Comment