我有这个调用用.net 2010编写的Web服务的vbscript。 我在最后一行收到错误。无法弄清楚。 这是网络服务: 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
答案 0 :(得分:0)
这不是VBScript问题,它是一个xpath问题。 xmldoc2.documentElement.selectSingleNode("LeftCarShortTitle")
会尝试找到“LeftCarShortTitle”元素作为根的子元素....在您的情况下将无法正常工作,因为在此之前有各种级别,即{{1} }。
将您的xpath更新为:
<string><Root><FrontpageData>
这将遍历文档的后代,并找到您要查找的节点。