使用selectSingleNode时出现对象必需错误

时间:2018-09-13 19:28:33

标签: object asp-classic

我需要创建一个函数,在该函数中我可以传递预定义的xml和密钥,并且该函数将返回值。假设我的键值为FLGVIEWALL,那么我的代码应该返回true或false。该代码是使用经典ASP创建的,以前似乎可以使用。它可能是xml格式或其他格式的问题,现在在selectsinglenode行..对象中返回错误。有人可以帮我为什么我得到这个..我在这里做错了什么。

    Function GetNodeValueText(strRet, key)
        ' Initializes the node value
        dim nodeValue

        ' Creates the DOM xml
        Set objRet = CreateObject("MSXML2.DOMDocument")
        objRet.loadXML strRet
        objRet.setProperty "SelectionLanguage", "XPath" 
        objRet.setProperty "SelectionNamespaces", "xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns='http://myserver.com' " & _
            "xmlns:map='http://ws.apache.org/namespaces/axis2/map' xmlns:ax241='http://rpc.xml.coldfusion/xsd' " & _
            "xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"

        ' Gets the node value
        Set nodeValue = objRet.selectSingleNode("//ax241:entries[ax241:key='" & key & "']/ax241:value")

        ' Sets the return
        GetNodeValueText = nodeValue.text
    End Function

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
	<getADUserInfoResponse xmlns="http://myserver.com">
		<getADUserInfoReturn xsi:type="ns1:Map" xmlns:ns1="http://xml.apache.org/xml-soap">
			<item xmlns="">
				<key xsi:type="xsd:string">STATUS</key>
				<value xsi:type="xsd:string">Success</value>
			</item>
			<item xmlns="">
				<key xsi:type="xsd:string">ADUSERINFO</key>
				<value xsi:type="ns1:Map">
					<item>
						<key xsi:type="xsd:string">RESULTS</key>
						<value xsi:type="xsd:string">true</value>
					</item>
					<item>
						<key xsi:type="xsd:string">STCADUSERINFO</key>
						<value xsi:type="ns1:Map">
							<item>
								<key xsi:type="xsd:string">ACCOUNTDISABLED</key>
								<value xsi:type="xsd:string">false</value>
							</item>
							<item>
								<key xsi:type="xsd:string">CHALANSW</key>
								<value xsi:type="xsd:string">mom</value>
							</item>
							<item>
								<key xsi:type="xsd:string">FIRSTNAME</key>
								<value xsi:type="xsd:string">test</value>
							</item>
							<item>
								<key xsi:type="xsd:string">DTELASTLOGON</key>
								<value xsi:type="xsd:string"></value>
							</item>
							<item>
								<key xsi:type="xsd:string">CN</key>
								<value xsi:type="xsd:string">Gyan</value>
							</item>
							<item>
								<key xsi:type="xsd:string">EMAIL</key>
								<value xsi:type="xsd:string">gyan@gmail.com</value>
							</item>
							<item>
								<key xsi:type="xsd:string">FLGVIEWALL</key>
								<value xsi:type="xsd:string">true</value>
							</item>
							
						</value>
					</item>
				</value>
			</item>
		</getADUserInfoReturn>
	</getADUserInfoResponse>
</soapenv:Body>
</soapenv:Envelope>

0 个答案:

没有答案