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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XPATH XmlNode question

Status
Not open for further replies.

ccampbell

Programmer
Aug 16, 2001
201
US
I have an XML doc
Code:
- <Permit_Table>
- <Row>
  <PermitType2>EX LNTH/EX WGT</PermitType2> 
  <PermitNumber>06013620</PermitNumber> 
  <ExpireDate>01/01/2007</ExpireDate> 
  <PermitType>ANNUAL</PermitType> 
  <PermitValid>VALID</PermitValid> 
  </Row>
- <Row>
  <PermitType2>EX LNTH/EX WGT</PermitType2> 
  <PermitNumber>11234</PermitNumber> 
  <ExpireDate>01/01/2008</ExpireDate> 
  <PermitType>ANNUAL</PermitType> 
  <PermitValid>VALID</PermitValid> 
  </Row>
  </Permit_Table>

In VBScript I need to know how to loop through the XML and return the data to the user. Here is my code that I cannot get to work.

Code:
set retString = Server.CreateObject("MSXML2.DOMDocument")
set sPermitNum = retString.selectNodes("/ScreenOutputs/Permit_Table/Row")
Dim i
		For i = 0 To sPermitNum.Count - 1
			Response.Write(sPermitNum.ItemOf(i).InnerXml)

		Next

Any help would be greatly appreciated.
 
>Here is my code that I cannot get to work.

[1] You've to load the data file.

[tt]retString.load pathToXmlDoc 'depends on cases, server.mappath might be needed

[2] There is no such thing as innerXml. Neither you use .count, use .length instead. If I guess right, like this.
[tt]
dim s,j
for i = 0 To sPermitNum.[red]length[/red] - 1
s=""
for j=0 to sPermitNum.item(i).childnodes.length-1
s=sPermitNum.item(i).childNodes.item(j).xml & vbcrlf
next
response.write s
next
[/tt]
with further slight refinement if so desired.
 
Amendment
The corresponding line should be read as:
[tt]s=[red]s[/red] & sPermitNum.item(i).childNodes.item(j).xml & vbcrlf[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top