XElement.AncestorsAndSelf (XName) returns a filtered collection of elements : XElement « 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 » XML LINQ » XElementScreenshots 
XElement.AncestorsAndSelf (XName) returns a filtered collection of elements
  

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

    Public Shared Sub Main()
        Dim xmlTree As XElement = _ 
            <Root>
                <Child>
                    <GrandChild>element content</GrandChild>
                </Child>
            </Root>
        
        Dim GC As XElement = xmlTree.<Child>.<GrandChild>(0)
        Dim aas As IEnumerable(Of XElement= GC.AncestorsAndSelf("Child")
        For Each el In aas
            Console.WriteLine(el.Name)
        Next
       
    End Sub
End Class 

   
    
  
Related examples in the same category
1.Build an XElement from string
2.Create a single XML element
3.After elements
4.Before elements
5.Create an in-memory XML document
6.First name element has attributes
7.First name tag has child elements
8.FirstLast Or Default Example
9.First Last Example
10.FirstName tag's parent has child elements
11.Get first descendant
12.Using Xml Linq to output Html
13.Xml Literal with string variable
14.Xml literal with function return
15.Enumerate over the array to build an XElement
16.Create a query to convert the xml data into fields delimited by quotes and commas.
17.Convert comma separated value to Xml
18.Get child elements by name directly
19.Get value of each color using indexer
20.Is FirstName tag empty?
21.Is idperson tag empty?
22.Using Ling query to create Xml output
23.The Root property returns the top-level XElement
24.Set new value to Xml document
25.Selects an XElement using a XPath expression.
26.XElement Represents an XML element.
27.Selects an XElement using a XPath expression.
28.XElement Class represents an XML element.
29.Create XElement class.
30.Create XElement class from another XElement object.
31.Create XElement class with the specified name.
32.Create XElement class with the specified name and content.
33.XElement object content
34.XElement object array content
35.Create XElement class with the specified name and content.
36.Create XElement class from an XStreamingElement object.
37.XElement.AncestorsAndSelf Method returns a collection of elements that contain this element, and the ancestors of this element.
38.XElement.Attributes returns a collection of attributes of this element.
39.XElement.Attributes (XName) returns a filtered collection of attributes of this element
40.XElement.DescendantNodesAndSelf returns nodes that contain this element, and all descendant nodes
41.XElement.HasAttributes tells whether this element as at least one attribute.
42.XElement.HasElements tells whether this element has at least one child element.
43.XElement.IsEmpty tells whether this element contains no content.
44.XElement.LastAttribute gets the last attribute of this element.
45.XElement.Name Property gets or sets the name of this element.
46.XElement.NodeType Property gets the node type for this node.
47.XElement.SetValue sets the value of this element.
48.XElement.Value Property gets or sets the concatenated text contents of this element.
49.Imports xmlns and use it with XElement
50.XObject.Parent Property gets the parent XElement of this XObject.
51.Extensions.AncestorsAndSelf
52.Extensions.Descendants
53.Extensions.Descendants(T)
54.Extensions.Elements(T) returns a collection of the child elements
55.Extensions.Elements(T) returns a filtered collection of the child elements
56.Extensions.XPathEvaluate evaluates an XPath expression.
57.String content
58.Double content
59.DateTime content
60.String array content
61.Returns elements containing this element and all descendant elements
62.Returns a filtered collection of elements containing this element and all descendant elements of this element
63.Get Ancestors
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.