Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reference the root node
Message
De
01/04/2013 22:07:42
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
XML
Titre:
Reference the root node
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01569682
Message ID:
01569682
Vues:
56
I have a weird situation when referencing a node from the root node.

This is my GetXmlNodeValue() method:
        ' Get a XML node value
        ' expC1 Node
        Public Function GetXMLNodeValue(ByVal tcNode As String) As Boolean

            ' Reset
            cMessage = ""
            cNodeInnerText = ""
            cNodeInnerXML = ""

            ' 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

            Try
                cNodeInnerText = oXmlNode.InnerText
                cNodeInnerXML = oXmlNode.InnerXml
            Catch loError As Exception
                cMessage = loError.Message
                Return False
            End Try

            Return True
        End Function
This is how I call it:
        ' Get the model number
        If Not loXml.GetXMLNodeValue("//Root.Node/Model/ModelNumber") Then
            Return False
        End If
So, this works as I thought until I discovered something weird today. Basically, someone has added an additional root node. So, the full reference is now:

ThisIsTheAdditionalRootNode/Root.Node/Model/ModelNumber

And, when executing the same code, it does not go in the If Not, thus skip the Return False. I cannot understand why the GetXmlNodeValue() is still able to find the node. Isn't // an indication of the root search? Someone has added a useless root node, so this should fail.

Anyone knows why?
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform