tags:

views:

74

answers:

1

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.

A: 

You could try Sarissa. It works as cross browser wrapper to native XML Apis and might solve that problem.

M.L.
Thanks for the suggestion but i'd rather not use another js library if it could be handled by just fixing some of the code I already have. Do you maybe have another suggestion? I somehow feel that there is just some minor thing I overlooked.
hdr