Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Verifying if namespace exists
Message
From
10/09/2015 14:21:38
 
 
General information
Forum:
ASP.NET
Category:
XML
Environment versions
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01622469
Message ID:
01624478
Views:
38
>Yes. Snip:
>"The namespace whose name is http://www.w3.org/XML/1998/namespace is bound by definition to the prefix xml"

Very well, this is a method I call to load the namespaces in memory:
    ' 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 Function
This 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
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform