Use XPath to do a 'select' command : XPath « XML « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » XML » XPathScreenshots 
Use XPath to do a 'select' command
Use XPath to do a 'select' command
  
Imports System
Imports System.Xml
Imports System.Xml.Schema
Imports System.IO
Imports System.Data.SqlClient
Imports System.Collections
Imports System.Data


Public Class MainClass
    
    Shared Sub Main()
        Dim XDoc As New XmlDocument()
        XDoc.Load("book.xml")

        Dim XNodes As XmlNodeList
        XNodes = XDoc.DocumentElement.SelectNodes_
                                  "//Book[starts-with(@Name, 'C#')]/Order")
        Console.WriteLine("Found {0} Nodes", XNodes.Count)

        Dim XNode As XmlNode
        For Each XNode In XNodes
            Console.WriteLine("Book {0} ordered {1} {2}", _
                     XNode.ParentNode.Attributes.GetNamedItem("Name").Value, _
                     XNode.Attributes.GetNamedItem("Quantity").Value, _
                     XNode.InnerText)
        Next             
    End Sub
End Class



           
         
    
  
Related examples in the same category
1.Using XPathNavigator to select single node
2.XPathResultType.Number
3.XPathResultType.NodeSet
4.XPathResultType.Boolean
5.XPathResultType.String
6.Use the XPath return type to determine how to process the XPath expression
w_ww_.___j__a___v__a2_s__.c_o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.