Hello everyone,I am trying to create a page which uses javascript to select xml entries. The xml file would look like this:
<?xml version="1.0"?><entries><entry><date day="10" month="10" year="2006">log info</date></entry><entry><date day="15" month="10" year="2006">log info</date></entry><entry><date day="20" month="10" year="2006">log info</date></entry></entries>
I might put more nodes into each entry, but my sticking point has been selecting the entries using javascript. I am hoping to stick to just javascript for this selection process, because it's really the only thing I know. The javascript to select nodes currently looks like the following, but I'm missing a key part of course
var curdate = new Date(); var yy = curdate.getYear()+1900; var mm = curdate.getMonth()+1; var dd = curdate.getDate(); var x = xmlDoc.getElementsByTagName('entry'); for (j=0;j<x.length;j++) { if (x[j].childNodes[1].[b]??[/b]>=yy) { display the data code } }
I've tried getAttribute without success, but I might have done it wrong or I might be missing something else. I have javascript opening the xml file in a seperate part of my .js file, and this function would also be in there, running after the xml data is loaded. I've tested it by pulling all the entries out and displaying them, and that's working fine, it's just pulling a particular portion.My goal is to look at the current date, and then pull any entries occurring within 14 days. I have a feeling due to roll over to next months there's likely some gotchas in the javascript for that, but my focus right now is figuring out how to get those attributes correctly coded into the if statement. If anyone could slap the back of my head with the obvious I would greatly appreciate it, as I've read through many tutorials which show examples that just don't work when I try to use them.