In the previous LINQ to XML chapters, I demonstrated the core principles needed to perform XML queries using LINQ to XML. However, most of the examples are specifically designed to demonstrate an operator or a property. In this section, I want to provide some examples that are more solution oriented.
In the previous chapters, many of the examples would reach down into the XML hierarchy to obtain a reference to a particular element by calling the Element or Elements operators recursively until the desired element was reached.
For instance, many of the examples contained lines such as this:
IEnumerable<XElement> elements = xDocument.Element("BookParticipants").Elements("BookParticipant");
In this statement, I start at the ...