Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用XmlUtil(UFT 12.0)时XPath失败_Xpath_Vbscript_Xml Parsing_Hp Uft - Fatal编程技术网

使用XmlUtil(UFT 12.0)时XPath失败

使用XmlUtil(UFT 12.0)时XPath失败,xpath,vbscript,xml-parsing,hp-uft,Xpath,Vbscript,Xml Parsing,Hp Uft,给定以下XML: cci-sf-dev14.wellsfargo.com:425a9286:14998ac6245:-7e1e 425a9286:14998ac6245:-7e1d 1. 2014-11-10T00:14:49.243-08:00 cci-sf-dev14.wellsfargo.com P7 FNC cci-sf-dev14.wellsfargo.com 05426 287586861901211 电子计算机网络 GTST0793 ACF2 114 28758686190121

给定以下XML:


cci-sf-dev14.wellsfargo.com:425a9286:14998ac6245:-7e1e
425a9286:14998ac6245:-7e1d
1.
2014-11-10T00:14:49.243-08:00
cci-sf-dev14.wellsfargo.com
P7
FNC
cci-sf-dev14.wellsfargo.com
05426
287586861901211
电子计算机网络
GTST0793
ACF2
114
287586861901211
一般信息201205
真的
真的
段列表
有限的配置文件所需的数据
个人客户一般信息201205
真的
我正在尝试使用VBScript中的相对XPath访问
getCustomerInformation
标记

XMLDataFile=“C:\testReqfile.xml”
设置xmlDoc=XMLUtil.CreateXML()
加载文件(XMLDataFile)
打印xmlDoc.ToString
'xmlDoc.AddNamespace“ns”,“xmlns:soapenv”=http://schemas.xmlsoap.org/soap/envelope/"
Set childrenObj=xmlDoc.ChildElementsByPath(“/*[contains(@xmlns,'getCustomerInformation')]”)
msgbox childrenObj.Count

但是无法返回节点。

您的XPath表达式无法工作,因为

<getCustomerInformation xmlns="http://service.wellsfargo.com/provider/ecpr/customerProfile/inquiry/getCustomerInformation/2012/05/">
正如他在回答中已经解释的那样,
xmlns
定义了一个名称空间,因此不能像常规属性那样进行访问。我没有使用XmlUtil的经验,但在标准VBScript中,您可以选择如下节点:

Set xml=CreateObject(“Msxml2.DOMDocument.6.0”)
xml.async=False
xml.load“C:\path\to\your.xml”
如果xml.ParseError,那么
WScript.Echo xml.ParseError.Reason
WScript.Quit 1
如果结束
'定义命名空间别名“ns”
uri=”http://service.wellsfargo.com/provider/ecpr/customerProfile/inquiry/getCustomerInformation/2012/05/"
xml.setProperty“SelectionNamespaces”、“xmlns:ns=”&uri&“
'使用命名空间别名选择节点
Set nodes=xml.SelectNodes(“//ns:getCustomerInformation”)
Set childrenObj = xmlDoc.ChildElementsByPath("//*[local-name() = 'getCustomerInformation']")