Selects a collection of elements using an XPath expression. : XPath « XML LINQ « 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 LINQ » XPathScreenshots 
Selects a collection of elements using an XPath expression.
  

Imports System
Imports System.Xml
Imports System.Xml.XPath
Imports System.Linq
Imports System.Collections
Imports System.Collections.Generic
Public Class MainClass

   Public Shared Sub Main()
        Dim root As XElement = _
            <Root>
                <Child1>1</Child1>
                <Child1>2</Child1>
                <Child1>3</Child1>
                <Child2>4</Child2>
                <Child2>5</Child2>
                <Child2>6</Child2>
            </Root>
        Dim list As IEnumerable(Of XElement= root.XPathSelectElements("./Child2")
        For Each el As XElement In list
            Console.WriteLine(el)
        Next

    End Sub

End Class

   
    
  
Related examples in the same category
1.Loop through the query results and display the information to the screen.
2.Use XPath to get the tasks for each employee.
3.Selecting node by XPath
4.Evaluates an XPath expression, resolving namespace prefixes using the specified IXmlNamespaceResolver.
5.Selects a collection of elements using an XPath expression.
6.XPathExpression Class provides a typed class that represents a compiled XPath expression.
w__w___w.__ja_va___2s__._com__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.