I am working through w3schools and am stuck on a bit of XML. The following page shows a parsed XML file which has a single node (with several children) displayed as HTML. I always challenge myself to push the code before me to encourage more meaningful learning, but this time I am stuck! Here is the link to the page:
http://www.w3schools.com/xml/tryit.asp?filename=tryxml_app_first
The XML file is a mock 'CD catalogue' that contains a list of CD nodes, containing child nodes of artist, title, etc. The page displays a single CD node, selected by the lines:
x=xmlDoc.getElementsByTagName("CD");
i=0;
What I am trying to do is create a button which, when pressed, increases the value of "i" by 1. Essentially a 'next' button. I have tried to create a button/function combo while treating "i" as a variable. That fails, so I get the feeling that I don't actually understand how XML/DOM works...
I understand that this may be a trivial question but I have tried different search terms on Google and Stack Overflow but with no success. If there's a way to do what I'm trying to, please let me know!
Edit: Eek! I'm so stupid and was so engrossed in this little self-challenge that I didn't even read on to the next section of the page on w3schools, titled "Navigate Between the CDs":
http://www.w3schools.com/xml/xml_applications.asp
I will leave this question as is for people who Google for this, but if you look at w3school's example (click "Try it yourself", is it the most efficient way to do it?