【问题标题】:Accesing XML values with classic asp through xmlhttp通过 xmlhttp 使用经典 asp 访问 XML 值
【发布时间】:2011-11-17 04:54:03
【问题描述】:

我有,也许是微不足道的问题,但由于缺乏文档,我无法在 Google 上找到任何答案。我正在从我的域向另一个域发送请求,并针对返回 XML 的 Web 服务。我通过这段代码做到这一点:

url = "some url aiming at web service"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") 
    xmlhttp.open "GET", url, false 
    xmlhttp.send "" 
    xmlString = xmlhttp.responseText
set xmlhttp = nothing 

当我尝试打印 xmlString 时,它会返回完整的页面。如何访问特定节点和值?

XML 与此类似:

<grandpa>
   <father>value</father>
   <son>value</son>
</grandpa>

【问题讨论】:

    标签: xml asp-classic xml-parsing xmlhttprequest


    【解决方案1】:

    尝试使用 responseXML,它是一个功能齐全的 XML DOM,您可以在其中利用 selectSingleNode 和 XPath 表达式来获取节点,例如

    xmlhttp.responseXML.selectSingleNode("//grandpa/father");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多