Select value of attribute in xml through ASP

Can you someone help with how to get the value of date to be displayed right before the description in the code below,

thank you,

strDate = "4/18/2006"
intMaxEvents = 3

Set oXMLHTTP = Server.CreateObject("Microsoft.XMLDOM")
oXMLHTTP.async = False
<?xml version="1.0" encoding="UTF-8"?>
          <event date="4/17/2006">
          <event date="4/20/2006">
          <event date="4/17/2006">
               <description>Run Marathon</description>
          <event date="4/17/2006">
          <event date="4/20/2006">
               <description>Another Item on another day</description>


If oXMLHTTP.Load(Server.MapPath("calendar.xml")) Then
     Set oEventNodes = oXMLHTTP.documentElement.selectNodes("//event[@date>='" & strDate & "']")
     Response.Write "<ul>"    
     For i = 0 To (oEventNodes.Length - 1)
          Response.Write "<li>" & oEventNodes.Item(i).SelectSingleNode("description").Text & "</li>"
          If i = (intMaxEvents - 1) Then Exit For
     Response.Write "</ul>"
     Response.Write "XML file did not load"
End If
Set oXMLHTTP = Nothing
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Like this:

Response.Write "<li>" & oEventNodes.Item(i).SelectSingleNode("@date").Text & "</li>"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
- oEventNodes is a collection of <event> node objects.
- A node object has an attributes collection, and this collection has a getNamedItem method which returns an attribute object
- The attribute object has a value property

So, to access the 'date' attribute of the <event> node inside your For...Next loop try something like this

@deighc - Is there an advantage to doing it the way you suggested compared to the way I did it?  I work a fair amount with XSL, so it seemed intuitive for me to just provide an XPath allow with the SelectSingleNode method, but I am curious if your way may have some advantages that I am not aware of...
> Is there an advantage to doing it the way you suggested compared to the way I did it?


It was my understanding that attributes could only be accessed programatically through the attributes collection. I didn't realise that they were also accessible by using the SelectSingleNode() method. But this makes sense since an XML parser builds a 'node tree' from all element and attribute nodes.

- I've learned something
- @tamilgirl77, please don't accept my answer over @peterxlane's as they're functionally identical
tamilgirl77Author Commented:
Thank you both for helping me out,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.