vbscript xml 问题 [英] vbscript xml problem

查看:26
本文介绍了vbscript xml 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个调用 .net 2010 编写的 Web 服务的 vbscript.我在最后一行出现错误.想不通这是网络服务:http://www.kollelbaaleibatim.com/services/getinfo.asmx/GetFronpageInfo

I have this vbscript that calls a web service written in .net 2010. I'm getting an error at the last line. Can't figure it out. This is the webservice: http://www.kollelbaaleibatim.com/services/getinfo.asmx/GetFronpageInfo

   Dim xmlDOC
    Dim bOK
    Dim J
    Dim HTTP
    Dim ImagePathLeftCar, ImagePathRightCar
    Dim CarIDLeft, CarIDRight
    Dim ShortTitleLeftCar, ShortTitleRightCar
    Dim DescriptionLeftCar, DescriptionRightCar 
    Dim PriceLeftCar, PriceRightCar

    Set HTTP = CreateObject("MSXML2.XMLHTTP")
    Set xmlDOC =CreateObject("MSXML.DOMDocument")
    xmlDOC.Async=False

    HTTP.Open "GET","http://www.kollelbaaleibatim.com/services/getinfo.asmx/GetFronpageInfo", false 
    HTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    HTTP.Send()  

    dim xmldoc2   
    set xmldoc2 = Server.CreateObject("Microsoft.XMLDOM")
    xmldoc2.async = False 
    bOK = xmldoc2.load(HTTP.responseXML)

    if Not bOK then
        response.write( "Error loading XML from HTTP")
    end if

    response.write( xmldoc2.documentElement.xml)'Prints a good looking xml
      ShortTitleLeftCar = xmldoc2.documentElement.selectSingleNode("LeftCarShortTitle").text 'ERROR HERE

推荐答案

这不是 VBScript 问题,而是 xpath 问题.xmldoc2.documentElement.selectSingleNode("LeftCarShortTitle") 将尝试找到 "LeftCarShortTitle" 元素作为根的子元素......这在你的情况下不起作用因为在此之前有多个级别,即 .

This isn't a VBScript issue, it is an xpath issue. xmldoc2.documentElement.selectSingleNode("LeftCarShortTitle") will try find the "LeftCarShortTitle" element as a child of the root....which in your case won't work as there are various levels before this i.e. <string><Root><FrontpageData>.

将您的 xpath 更新为:

Update your xpath to be:

//LeftCarShortTitle

这将遍历文档的后代并找到您要查找的节点.

This will traverse the descendants of the document and should find the node your looking for.

这篇关于vbscript xml 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆