将经典.ASP应用程序转换为.ASPX,下面的函数将获取XML片段。它在asp中工作正常但是给了我一个comipilation错误"错误BC30456:getAttribute不是MSXML.IXMLDOMNode"的成员。在.ASPX
Function ExtractDataFromXML(ByRef sInputXML As String) As String
Dim XMLDom As MSXML.DOMDocument
Dim currNode As MSXML.IXMLDOMNodeList
Dim Node As MSXML.IXMLDOMNode
Dim sError As String
Dim sResult As String
XMLDom = New MSXML.DOMDocument
XMLDom.async = False
If (XMLDom.loadXML(sInputXML) = False) Then
sResult = "XML Parse Error: " & XMLDom.parseError.reason & " code=" & XMLDom.parseError.errorCode & " " & Chr(13) & Chr(10)
Else
currNode = XMLDom.selectNodes("//push-response")
For Each Node In currNode
sError = Node.selectSingleNode("response-result").getAttribute("code")
If sError = "1000" Then
sResult = Node.selectSingleNode("address").Text
Else
sResult = "Error " & sError & ": " & Node.selectSingleNode("response-result").getAttribute("desc")
End If
Next Node
End If
ExtractDataFromXML = sResult
End Function
我必须使用错误类型的xml文档界面,但我不确定应该使用哪种界面。
有人能给我一些关于我需要对此代码做什么才能让它在.ASPX / VBScript环境中工作的线索,请...?
答案 0 :(得分:1)
attributes是IXMLDOMNamedNodeMap
类型的IXMLDOMNode的属性所以我会使用Node.selectSingleNode("response-result").attributes.getNamedItem("code")