Mega Code Archive

 
Categories / VB.Net / XML LINQ
 

XObject Parent Property gets the parent XElement of this XObject

Imports System Imports System.Xml Imports System.Xml.Schema Class MainClass     Shared Sub Main()         Dim doc As XDocument = _             <?xml version="1.0"?>             <!--A comment in the document.-->             <Root>                 <Child>content</Child>             </Root>         Dim child As XElement = doc.Descendants("Child").First()         Dim root As XElement = child.Parent         Console.WriteLine(root.Name)     End Sub End Class