Welcome to WebmasterWorld Guest from 184.72.177.182

Forum Moderators: httpwebwitch

Message Too Old, No Replies

How to access xml attributes?

xml newbie needs help

     
6:25 pm on Sep 6, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:June 11, 2003
posts:417
votes: 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)?

7:17 pm on Sept 6, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:June 11, 2003
posts:417
votes: 0


...just found a solution

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

7:29 pm on Sept 6, 2004 (gmt 0)

New User

10+ Year Member

joined:Sept 3, 2004
posts:30
votes: 0


Something like

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

7:32 pm on Sept 6, 2004 (gmt 0)

New User

10+ Year Member

joined:Sept 3, 2004
posts:30
votes: 0


That'll teach me to refresh before posting .....
8:25 pm on Sept 6, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:June 11, 2003
posts:417
votes: 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).

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members