rangi rangi - 4 months ago 40
ASP.NET (C#) Question

VBScript getAttribute is not a member of MSXML.IXMLDOMNode

Converting a classic .ASP application to .ASPX and the function below takes in an XML snippet. It works fine in asp but gives me a comipilation error "error BC30456: getAttribute is not a member of MSXML.IXMLDOMNode" in .ASPX

Function ExtractDataFromXML(ByRef sInputXML As String) As String
Dim XMLDom As MSXML.DOMDocument
Dim currNode As MSXML.IXMLDOMNodeList
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)
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
sResult = "Error " & sError & ": " & Node.selectSingleNode("response-result").getAttribute("desc")
End If
Next Node
End If
ExtractDataFromXML = sResult
End Function

I must be using the wrong type of xml document interface but I'm not sure what interface I should use.

Can anyone give me a clue on what I need to do to this code to get it to work in the .ASPX/VBScript environment, please..?


attributes is a property of IXMLDOMNode of type IXMLDOMNamedNodeMap

so I would use Node.selectSingleNode("response-result").attributes.getNamedItem("code")