Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Verifying if namespace exists
Message
From
24/07/2015 16:17:54
 
 
To
24/07/2015 09:57:17
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:
01622485
Views:
36
>I have this method to add a namespace from my XML class:
>
>
>    ' Add a namespace
>    Public Function AddNamespace() As Boolean
>        Dim lcNamespace As String = ""
>        Dim lcUri As String = ""
>        Dim llSuccess As Boolean = False
>
>        ' Reset the values
>        cMessage = ""
>
>        ' 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
>
>                    ' Create the XmlNameSpaceManager object once
>                    ' This is needed as we could add several namespaces
>                    If oXmlNameSpaceManager Is Nothing Then
>                        oXmlNameSpaceManager = New XmlNamespaceManager(oXmlDocument.NameTable)
>                    End If
>
>                    oXmlNameSpaceManager.AddNamespace(lcNamespace, lcUri)
>                    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
>
>
>However, I just found out that even if the namespace does not exist, this will not go in the Catch as an exception.
>
>I would like to make an adjustment that if the namespace does not exist, that it will go in the exception.
>
>Is there a way to verify if a namespace exists?

https://msdn.microsoft.com/en-us/library/system.xml.xmlnamespacemanager.hasnamespace(v=vs.110).aspx ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform