Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XML manipulation returns wrong node
Message
From
07/01/2011 16:46:48
 
 
To
All
General information
Forum:
ASP.NET
Category:
XML
Title:
XML manipulation returns wrong node
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01495210
Message ID:
01495210
Views:
100
I have a XML like this:
<Root>
   <VehicleInfo>
      <VINInfo />
   </VehicleInfo>
   <ComparableVehicles>
      <VehicleInfo>
         <VINInfo>
            <VIN>
               <VINNum>Something</VINNum>
            </VIN>
         </VINInfo>
      </VehicleInfo>
   </ComparableVehicles>
</Root>
I use this method to verify if a XML node exist:
        ' See if a node exists
        ' expC1 Node
        Public Function IsXMLNode(ByVal tcNode As String) As Boolean

            ' 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
                Return False
            End If

            Return True
        End Function
I use this code to verify if a specific XML node exists:
' If we have the //VehicleInfo/VINInfo/VIN/VINNum
If loXml.IsXMLNode("//VehicleInfo/VINInfo/VIN/VINNum") Then
End If
And, it does find it. However, that branch is not under the root but under ComparableVehicles. Why does it find it?
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
Next
Reply
Map
View

Click here to load this message in the networking platform