简体   繁体   中英

Classic ASP & XML

I've got the following XML and the below ASP statement is working, but I need to get a specific tag rather than response.write everything. ie I want to get "Document_Name", or "Document_Size".

Does anyone know how I can do this?

<PropertyImages>
     <Image>
         <Document_Name>tes1.png</Document_Name>
         <Document_Size>123</Document_Size>
     </Image>
     <Image>
          <Document_Name>Test.png</Document_Name>
          <Document_Size>123</Document_Size>
     </Image>
</PropertyImages>

This is the code ..

Set objHdl = objLst.item(i)

Set PropertyImages = ObjHdl.getElementsByTagName("PropertyImages")

for x = 0 to (PropertyImages.Length-1)
    Set Image = PropertyImages.item(x)

    response.write "Image=" & Image.text & "<br>"
next

This seems to work, but only brings back the first image details? I have a number of images I need to get back on a particular property.

Set images = objHdl.getElementsByTagName("Image")
For each image in images
     ImageURL = image.SelectSingleNode("Image_URL").text
Next

I believe you'll want something like this

Set imageNodes =  objXMLDOM.documentElement.selectNodes("Image")
For Each imageNode In imageNodes 
    documentName = imageNode.selectSingleNode("Document_Name").Text
    ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM