I’m creating a video library and have an XML document split up by video category such as:
<video>
<comedy>
<url>bla</url>
<title>blabla</title>
</comedy>
<action>
<url>bla</url>
<title>blabla</title>
</action>
</video>
And so on. I use an XMLHttpRequest to getElementsByTagName() for the genre I want and it is working fine.
My question is: I want to create a ‘Most Recent’ category, that would just pick the first 16 (or however many) off the top of the XML file, regardless of category. Is there a way to accomplish this?
Iterate over the childNodes of the root-element, and check if the node is a element-node(childNodes will also return textNodes for the whitespaces)
In some browsers there may also be a children-property which only returns children that are element-nodes, but this is no standard so I wouldn’t suggest to use it.
When you use a library like jQuery it would be much easier, to have the same result you only need: