I am trying to extract a value of a node in xml. I am facing some problems due to its name space. In below xml, I want the value of ‘faultstring’ tag.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>Error</faultcode>
<faultstring>Invalid combination of Username and Password.</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I am using following code to get the value. But it throws error.
Dim xmlDoc As New XmlDocument
Dim namespaces As XmlNamespaceManager = New XmlNamespaceManager(xmlDoc.NameTable)
namespaces.AddNamespace("ns", "SOAP-ENV")
xmlDoc.Load("SOAP.xml")
Dim oNode = xmlDoc.SelectSingleNode("ns:Envelope/ns:Body/ns:Fault/faultstring")
MsgBox(oNode.InnerXml.ToString)
I am not getting any solution. If anyone can help with this ! Thank you !
As i did not get any help on my question, I tried myself. The solution code goes as follows.
It works fine now !! cheerss !!