I am trying to extract the node value in xml. I am facing some problems due to its namespace. In the below xml, I want the value of the tag "faultstring".
<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 use the following code to get the value. But it causes an 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 do not get any solution. If anyone can help with this! Thanks!
source share