Asp XML Parsing

后端 未结 3 1921
慢半拍i
慢半拍i 2020-12-10 18:28

I am new to asp and have a deadline in the next few days. i receive the following xml from within a webservice response.

print(\"

        
3条回答
  •  借酒劲吻你
    2020-12-10 19:16

    By ASP I assume you mean Classic ASP? Try:

    Dim oXML, oNode, sKey, sValue
    
    Set oXML = Server.CreateObject("MSXML2.DomDocument.4.0")
    oXML.LoadXML(sXML)
    
    For Each oNode In oXML.SelectNodes("/user_data/person_info/attribute")
      sKey = oNode.GetAttribute("name")
      sValue = oNode.Text
      ' Do something with these values here
    Next
    
    Set oXML = Nothing
    

    The above code assumes you have your XML in a variable called sXML. If you are consuming this via an ServerXMLHttp request, you should be able to use the ResponseXML property of your object in place of oXML above and skip the LoadXML step altogether.

提交回复
热议问题