Having an xml file like:
<?xml version="1.0" encoding="UTF-8"?>
<Data Version="3" xsi:schemaLocation="uuid:ebfd9-45-48-a9eb-42d Data.xsd" xmlns="uuid:ebfd9-45-48-a9eb-42d" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Info>
<Muc>Demo</Muc>
</Info>
</Data>
I am doing
Dim m_xmld As XmlDocument
m_xmld = New XmlDocument()
m_xmld.Load("myXML.xml")
Dim test As XmlNode
test = doc.SelectSingleNode("Data/Info", GetNameSpaceManager(m_xmld))
having:
Public Shared Function GetNameSpaceManager(ByRef xDoc As XmlDocument) As XmlNamespaceManager
Dim nsm As New XmlNamespaceManager(xDoc.NameTable)
Dim RootNode As XPathNavigator = xDoc.CreateNavigator()
RootNode.MoveToFollowing(XPathNodeType.Element)
Dim NameSpaces As IDictionary(Of String, String) = RootNode.GetNamespacesInScope(XmlNamespaceScope.All)
For Each kvp As KeyValuePair(Of String, String) In NameSpaces
nsm.AddNamespace(kvp.Key, kvp.Value)
Next
Return nsm
End Function
However I keep on getting "Nothing"
when reading the xml. Is there a way to ignore the namespaces?. The issue is that some namespaces may vary between files, thats why I added GetNameSpaceManager
function...