How do I use jQuery to read the first item in the contents of an XML file called music.xml, display them in a DIV for five seconds, read the next XML item and display that for five seconds, loop through the XML file and then start again from the beginning?
HTML:
<div id="music">
<div id="albumcover"></div>
<div id="songdescription"></div>
</div>
music.xml
<songs>
<item>
<image>music_01.jpg</image>
<description>Description of first song</description>
</item>
<item>
<image>music_02.jpg</image>
<description>Description of second song</description>
</item>
<item>
<image>music_03.jpg</image>
<description>Description of third song</description>
</item>
</songs>
First off, the way that I know how to parse these using jQuery will give problems with the
imagetag (edit: only if you parse text; XML turns out to be fine), as once you wrap it in jQuery it will convert<image>text</image>to<img>text. You can deal with that, but it’s not pretty. So let’s assume you’ve renamed<image>to<cover>.Working jsFiddle, minus the
$.ajaxrequest part.