I\'ve got the unpleasurable task of working on a Classic ASP site (VBSCRIPT) and need to parse out the following information in a loop.
Switch to using xpath instead and it will be much easier.
Dim nodes
nodes = objXML.selectNodes( "//products" )
Dim images
For each node in nodes
Response.Write( "<ul>" )
Response.Write( "<li>Ref: " + node.selectNodes( "@ref" ).Text + "</li>" )
images = node.selectNodes( "images/image" )
For each image in images
Response.Write( "<li>Image: " + image.selectNodes( "@ref" ).Text + "</li>" )
Next
Response.Write( "</ul>" )
Next
I'm a JScript ASP coder, like you not done VBScript for an age so the above "might" need a bit of polish (I had to strip out all the ";" at the end of the all the lines, such is the habit of adding them) but should point you in the right direction at least.
Hope that helps.
Try the following command to get the attribute value specifically for the image node:
node.Attributes.getNamedItem("ref").Text
Yeah, having to work in classic ASP occasionally transports me back to the Stone age too... I feel your pain!
IIRC, in your second code snippet, you just need to add :
for each node in childNodes
Response.Write node.nodeName & " = " & node.text & "<br />" & vbCrLf
'***Add the following:
For Each att in node.Attributes
Response.Write att.Name & " = " & att.text & "<br />" & vbCrLf
Next
next