Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding a child node end up with namespace
Message
From
20/06/2012 11:35:58
 
 
To
20/06/2012 11:31:24
General information
Forum:
ASP.NET
Category:
XML
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01546444
Message ID:
01546446
Views:
40
Because the node I am trying to add is within a namespace, I need to pass it to the method. So, I adjusted the method like this:
        ' Add an element
        ' expC1 Node
        ' expC2 Element
        ' expC3 Namespace
        '       Optional
        Public Function AddXMLElement(ByVal tcNode As String, ByVal tcElement As String, _
         Optional ByVal tcNamespace As String = "") As Boolean

            ' Create the node
            Try
                oXmlElement = oXmlDocument.CreateElement(tcElement, tcNamespace)
            Catch loError As Exception
                cMessage = loError.Message
                Return False
            End Try

            ' Select the node
            If oXmlNameSpaceManager Is Nothing Then
                oXmlNode = oXmlDocument.SelectSingleNode(tcNode)
            Else
                oXmlNode = oXmlDocument.SelectSingleNode(tcNode, oXmlNameSpaceManager)
            End If

            ' See if we obtained the node
            If oXmlNode Is Nothing Then
                cMessage = oApp.StrTran(cNodeDoesNotExist, "##Node##", tcNode)
                Return False
            End If

            ' Add the node
            oXmlNode.AppendChild(oXmlElement)

            cXml = oXmlDocument.OuterXml
            Return True
        End Function
Thus, I obtain:
<ReferenceInfo/>
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