Click to See Complete Forum and Search --> : selecting nodes using an attribute?


buddhadog
10-04-2006, 12:17 PM
Hello, I am trying to use javascript to go through an xml file and select/display nodes based on a date attribute found in each node. My xml-related question is, how would you extract this attribute in a cross-browser-friendly way? If each entry were:

<entry>
<data date="20061004">October 4, 2006</date>
</entry>

And I was using a loop to check each entry's date attribute and select entries which were within 10 days of the current date (using getDate), how would you reference the attribute value in the XML file? I believe I can resolve the javascript side of comparing values, I'm just trying to figure out how to assign that attribute value to a variable.

I aplogize if this is the wrong place to ask or if do not make sense. :( Thank you for your assistance!

buddhadog
10-05-2006, 11:59 AM
Does anyone know what kind of xpath code would be used for that? Something like:

document.evaluate(entries/entry/data[@date>=x]), where x is a variable you've already set?

mudelta
10-08-2006, 11:22 AM
euhm i guess you have to use XQUERY,

but i know too little too explain you.

http://www.w3schools.com/xquery/default.asp

buddhadog
10-10-2006, 03:27 PM
I've read through those examples, sadly it only works in theory with that site, and then only with IE. I've tried putting many of their examples to practice, only to find most of it doesn't work.

mudelta
10-10-2006, 03:44 PM
i'm sorry it didn't help you.

My knowledge of xml is too little too help you