VBScript Can not Select XML nodes

前端 未结 3 1146
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-28 18:00

I am trying to Select nodes from some webservice response XML to no avail. For some reason I am able to select the root node (\"xmldata\") however, when I try to drill deeper(\"

3条回答
  •  生来不讨喜
    2021-01-28 18:37

    Ok, so I finally worked out what I was doing wrong. As the xml I was retrieving was from a webservice, and I had limited information about it, I used the following to write the xml to the page so that I could see how it was structured.

    Response.Write oXMLHttp.ResponseXml.xml
    

    For some reason(maybe someone could fill this part in) it wrote all the XML tags in lower case. It turns out that after some investigation and after doing the following I found out that this was not the truth!

    dim nodeList
    Set nodeList = xmlDoc.SelectNodes("//xmldata/")
    
    for each item In nodeList
        response.write(item.text & " -> Tag Name: " & item.nodeName & "
    ") Next 'this wrote the following to the page '22506 -> Tag Name: CustomerID 'Jim -> Tag Name: FirstName 'N -> Tag Name: IsSuperAdmin 'Jones 2 -> Tag Name: LastName

    As you can see the 'nodeName' property output shows the tags to be camel case. So that ResponseXML was rather misleading and seeing XPath is case sensitive was preventing me from selecting the Nodes in question.

提交回复
热议问题