Showing posts with label xml. Show all posts
Showing posts with label xml. Show all posts

Sunday, September 21, 2008

LINQ to XML

Simple Query Sample


Module Module1

Sub Main()
Dim doc = XDocument.Load("c:\books.xml").Elements
Dim query = From data In doc.Elements _
Where data.Element("title") = "Python"
For Each g In query
Console.WriteLine(g.Element("author").Value)
Next
Console.ReadLine()
End Sub

End Module

Sample File

<books>
<book><title>Python</title><author>Guido</author></book>
<book><title>Haskell</title><author>Books</author></book>
</books>

LINQ to XML Samples

A few samples on querying XML with LINQ
http://www.thomasclaudiushuber.com/blog/tag/linq/