Parsing, processing, and generating XML

Some apps, especially apps used with existing systems, need to be able to parse and generate XML.

Getting ready

For this recipe, we need to have an existing XML file stored in the Assets folder. The structure of the XML file that we will use in this recipe is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<bookshelf>
  <book title="book title">
    <authors>
      <author firstname="name" lastname="surname"/>
      <author ... />
    </authors>
  </book>
  <book>...</book>
</bookshelf>

How to do it...

There are many ways to handle XML, but in this recipe, we will use Language-Integrated Query (LINQ) to XML. One of the most common things to do with XML is to read it, usually from a remote source. Let's take a look at the following ...

Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.