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.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.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
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.