The LINQ to XML API

In the previous chapter, I demonstrated creating an XML document using the W3C DOM XML API and just how cumbersome that API can be. I also showed you some of the techniques I have seen used to circumvent the pain it causes.

I also let you in on a seemingly little-known secret about LINQ: the fact that LINQ is not just about data queries, it is also about XML. I told you there was a new XML API on the horizon, and that API is the LINQ to XML API.

Now, there is a better, or at least simpler, way to construct, traverse, manipulate, and query XML, and it's called LINQ to XML. In this chapter, I show you how to create, manipulate, and traverse XML documents using the LINQ to XML API, as well as how to perform searches on an XML object.

For the examples in this chapter, I created a console application. However, before you can leverage this new API, you need to add a reference to your project for the System.Xml.Linq assembly if it is not already present.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset