Syntax Error? When parsing XML value
Posted
by
Ace Munim
on Stack Overflow
See other posts from Stack Overflow
or by Ace Munim
Published on 2013-10-25T15:47:56Z
Indexed on
2013/10/25
15:53 UTC
Read the original article
Hit count: 232
JavaScript
|Xml
I don't know if I'm having a syntax error but the compiler is giving me
TypeError: 'undefined' is not an object (evaluating 'xmlDoc.getElementsByTagName("icon")[i].childNodes')
Its me giving me this problem when im parsing the XML
from my server
, my actual javascript code is like this
var xmlDoc = Obj.responseXML;
var count = 0;
if(xmlDoc){
while(count <= xmlDoc.getElementsByTagName("item").length){
document.getElementById("flow").innerHTML += "<div class='item'><img class='content' src='" + xmlDoc.getElementsByTagName("icon")[i].childNodes[0].nodeValue.replace(/\s+$/g,' ') +"' /></div>";
count++;
}
}else{
alert("Unable to parse!");
}
and my XML goes like this.
<feed>
<item>
<title>Given Title</title>
<icon>
http://i178.photobucket.com/albums/w255/ace003_album/Logo-ETC-RGB-e1353503652739.jpg
</icon>
</item>
<item>...</item>
<item>...</item>
<item>...</item>
<item>...</item>
<item>...</item>
<item>...</item>
</feed>
i just want to parse the image link and to show it.
© Stack Overflow or respective owner