XML DOM Help needed
August 30, 2007 9:25 PM
Subscribe
XML DOM question: Help a newbie. I can't figure out how to do something that seems so simple. I'm writing an extremely simple RSS reader that creates a select control. Each option element needs only to be filled with the values of the "link" and "title" elements but I can't figure out how to reference them by name.
In the RSS its basicaly only the "item" elements i'm interested in and "link" and "title" are two elements which are its children that I need to fetch the values for
Heres my initial code (ASP):
-------------------------------------------------------------------------
Set Root=source.documentElement
Set PodcastList=Root.getElementsByTagName("item")
For Each Podcast In PodcastList
Set Podcast_URL = [HOW?]
Set Podcast_title = [HOW?]
Response.write("<option value=""" & Podcast_URL.text & """>" & Podcast_URL.text & "</option>")
Next
--------------------------------------------------------------------------
What I can't figure out is how to request just the element i want by its name without using getelementsbyname() since that returns a list and there seem to be properties available to return single elements like firstChild or lastChild so it seems logical that there would be a method to do it for a single named element. I know xpath is probably what I need but i'm not at the learning stage where I know how to incorporate that into my code.
Thanks for your help!
posted by postergeist to technology (4 comments total)
so if x=getelementsbyname("myname");
then x[0] gives you the element you want.
posted by juv3nal at 11:24 PM on August 30, 2007