homepage Welcome to WebmasterWorld Guest from 50.16.112.199
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
How to access xml attributes?
xml newbie needs help
TravelSite

10+ Year Member



 
Msg#: 33 posted 6:25 pm on Sep 6, 2004 (gmt 0)

I'm trying to add xml content to my site, using asp and "Microsoft.XMLDOM". So far I can display xml data by using lines such as:

Response.Write xmlObj.getElementsByTagName("AnItem").item((counter)).text

This allows me to access the elements I need from xml docs such as:

<AnObject>
<AnItem id="1245">Item Details go here</AnItem>
</AnObject>

The question is how do I access the attribute tags (e.g. the "id" part of the above example)?

 

TravelSite

10+ Year Member



 
Msg#: 33 posted 7:17 pm on Sep 6, 2004 (gmt 0)

...just found a solution

set temp=xmlObj.getElementsByTagName("Details").item((counter))
AttID=temp.Attributes.getNamedItem("id").Text
response.write AttID

irnbru

10+ Year Member



 
Msg#: 33 posted 7:29 pm on Sep 6, 2004 (gmt 0)

Something like

.item((counter)).attributes.getNamedItem("id").text?

irnbru

10+ Year Member



 
Msg#: 33 posted 7:32 pm on Sep 6, 2004 (gmt 0)

That'll teach me to refresh before posting .....

TravelSite

10+ Year Member



 
Msg#: 33 posted 8:25 pm on Sep 6, 2004 (gmt 0)

Hey irnbru,

Thanks anyway. I spent several hours trying to figure it out before posting...only to find a solution a few minutes later (typical).

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved