代码之家  ›  专栏  ›  技术社区  ›  Itay.B

vbscript xml问题

  •  0
  • Itay.B  · 技术社区  · 14 年前

    我有一个vbscript,它调用用.NET2010编写的web服务。 这是Web服务: 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
    
    1 回复  |  直到 14 年前
        1
  •  0
  •   James    14 年前

    这不是VBScript问题,而是xpath问题。 xmldoc2.documentElement.selectSingleNode("LeftCarShortTitle") 我会努力找到 <string><Root><FrontpageData> .

    将xpath更新为:

    //LeftCarShortTitle

    这将遍历文档的子体,并应找到您要查找的节点。