Hi everyone,
I have a little problem. When I try to navigate between similar tags in my xml file it just wont jump to the next item. The text is displayed in a div (id=textb). Basically it gets all the contents from the xml file but for some reason my next() function is not working.
Javascript:
xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET", "xml/main.xml", false);
xmlhttp.send();
b = xmlhttp.responseXML.getElementsByTagName("part");
var c = 0, d = 0, speed = 90, text = [];
function ticker() {
story = b[d].getElementsByTagName("txtb")[0].childNodes[0].nodeValue;
obj = document.getElementById("textb");
text[c] = document.createTextNode(story.charAt(c));
obj.appendChild(text[c]);
c++;
c != story.length && setTimeout(function() {
ticker()
}, speed)
}
function next()
{
if (d<b.length-1)
{
d++;
ticker();
}
};
XML:
<?xml version="1.0" encoding="utf-8"?>
<root>
<part>
<txtb>
bla1
</txtb>
</part>
<part>
<txtb>
bla2
</txtb>
</part>
</root>
If anyone has an idea how to make it work or why it's not working it would be very nice if you could help me here.