' Get the namespaces Private Function GetNamespace() As Boolean Dim llSuccess As Boolean = False Dim loXmlNode As XmlNode = Nothing ' Reset the values cMessage = "" cNamespaceCollection = "" Try ' Get the node list oXmlNodeList = oXmlDocument.SelectNodes("//namespace::*[not(. = ../../namespace::*)]") ' For each node For Each loXmlNode In oXmlNodeList ' If we already have one If cNamespaceCollection.Length > 0 Then cNamespaceCollection = cNamespaceCollection + oApp.cCR End If cNamespaceCollection = cNamespaceCollection + loXmlNode.LocalName + " " + loXmlNode.Value AddNamespace(loXmlNode.LocalName, loXmlNode.Value) Next llSuccess = True Catch loException As Exception cMessage = loException.Message End Try Return llSuccess End Function ' Add a namespace ' expC1 Namespace ' expC2 Uri Private Function AddNamespace(ByVal tcNamespace As String, ByVal tcUri As String) As Boolean Dim loObject(2) As Object ' Initialization loObject(1) = tcNamespace loObject(2) = tcUri oNamespace.Add(loObject) Return True End FunctionThis is the method I call to verify if a namespace exists:
' If a namespace exists Public Function IsNamespace() As Boolean Dim lcNamespace As String = "" Dim lcNamespaceCollection As String = "" Dim lcUri As String = "" Dim lcUriCollection As String = "" Dim llSuccess As Boolean = False Dim loObject(2) As Object ' Reset the values cMessage = "" cNamespaceCollection = "" lExist = False ' Initialization lcNamespace = Trim(cNamespace) lcUri = Trim(cUri) ' If we have a Uri If lcUri.Length > 0 Then ' If we have a namespace If lcNamespace.Length > 0 Then Try ' For each namespace For Each loObject In oNamespace ' Initialization lcNamespaceCollection = loObject(1) lcUriCollection = loObject(2) ' If this is the one If UCase(lcNamespace) = UCase(lcNamespaceCollection) Then ' If this is the one If UCase(lcUri) = UCase(lcUriCollection) Then lExist = True End If End If Next llSuccess = True Catch loException As Exception cMessage = loException.Message End Try Else cMessage = cYouNeedToDefineTheNamespaceProperty End If Else cMessage = cYouNeedToDefineTheUriProperty End If ' Reset the values cNamespace = "" cUri = "" Return llSuccess End Function