Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NOT looping through elements

Status
Not open for further replies.

AndyApp

Programmer
Dec 20, 2001
259
GB
This is probably a really stupid question and i've probably not thought it through, but that hasn't stopped me in the past!

I'm getting an XML feed from a website using
Code:
Server.CreateObject("MSXML2.ServerXMLHTTP")

I've then got to move into two elements before I get to the one I want, I then want to loop through that element and pull certain things out. This I can do, however, sometimes I need to drop into further elements inside this 3rd element and I DON'T want to loop through them, just pull one out.

Like so:
Code:
<element1>
 <element2>
  <element3>
   ...stuff here
   <rogueElement>
    ...just want to drop in here once
   </rogueElement>
  ..loop round element3
  </element3>
 </element2>
</element1>

I might not be writing this clearly but I don't know any other way to move into elements without doing
Code:
for each x in y
which causes a loop
 
The procedure I would guess as you're being deliberately obscur there, is that [1] get the feed, [2] create domdocument object (freethreaded version or not), say oxmldoc (being domdocument or ixmldomelement) to parser it. Then it is this.
[tt] set onode=oxmldoc.selectsinglenode("/element1/element2/element3")[/tt]
Start then from there for whatever you want there-below.
 
So, let me just check, whereas before I was doing:
Code:
FOR EACH a in b.getElementsByTagName("Thing1")
 ..do stuff
 FOR EACH z IN a.getElementsByTagName("Thing2")
  ...do more stuff
 NEXT
NEXT
I now do:
Code:
FOR EACH a in b.getElementsByTagName("Thing1")
 ..do stuff
 SET z = a.selectsinglenode("Thing2")
  ...do more stuff
NEXT

Is that right? And i'm not being obscur(e), what more would you like to know?
 
If it is your own thing, then check what I posted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top