Imports System.Collections.Generic
Imports System.Collections
Imports System.Collections.ObjectModel
Imports System.Reflection
Imports System.Xml.Serialization
Imports System.Xml.Schema
Dim strXML as String = GetXml()
Dim XMLdoc As XmlDocument = New XmlDocument()
Dim XMLContent As XmlNodeList
Dim nsMgr As New XmlNamespaceManager(XMLdoc.NameTable())
nsMgr.AddNamespace("dflt", XMLdoc.DocumentElement.NamespaceURI)
nsMgr.AddNamespace("ns1", XMLdoc.DocumentElement.GetNamespaceOfPrefix("soap"))
nsMgr.AddNamespace("ns2", "http://namespacetwo")
nsMgr.AddNamespace("ns3", "http://namespacethree")
nsMgr.AddNamespace("ns4", "http://namespacefour")
nsMgr.AddNamespace("ns5", "http://namespacefive")
nsMgr.AddNamespace("ns6", "http://namespacesix")
XMLContent = XMLdoc.SelectNodes("/ns1:Envelope/ns1:Body/ns4:Response/ns4:Result", nsMgr)
XMLContent = XMLdoc.SelectNodes("/ns1:Envelope/ns1:Body/ns4:Response/ns4:Result/ns5:Data", nsMgr)
If Not XMLContent Is Nothing Then
For Each node As XmlNode In XMLContent
Console.WriteLine(Environment.Newline + "Selected Node: ")
Console.WriteLine(node.GetOuterXml())
Function GetXml() As String
Dim xml as String = <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="namespaceone" xmlns:xsi="namespacetwo" xmlns:xsd="namespacethree">
<Response xmlns="http://namespacefour">
<Data xmlns="http://namespacefive" xmlns:t="http://namespacesix">
</soap:Envelope>.ToString()
Public Module XmlSerializationHelper
<System.Runtime.CompilerServices.Extension> _
Public Function GetOuterXml(node as XmlNode, Optional indent as Boolean = true) as String
Using textWriter = New StringWriter()
Dim settings = New XmlWriterSettings() With { _
.OmitXmlDeclaration = true _
Using xmlWriter = System.Xml.XmlWriter.Create(textWriter, settings)
Return textWriter.ToString()