Chapter 3. XML as a Data Store

In this chapter, we will cover:

  • Opening a local XML file
  • Opening a remote XML file
  • Navigating the XML file to search
  • Object serialization to XML

Introduction

XML is the most popular open standard format for exchanging information in today's world. XML is human and machine readable. We don't go into detail about XML theory in this chapter, but if you want a better understanding on this topic you can refer to the online resource at http://www.w3.org/standards/xml/.

XML can be parsed using two different methods. The first method is using LINQ to XML, and the second method is using XmlReader. XmlReader is used for reading many documents or large documents that have the same structure. On the other hand, if you are reading a different structured XML, you can use LINQ to XML. XmlReader can be used for forward-only and read-only situations. If we need to write or create XML content, then the XmlWriter class is used. Caution should be exercised as large documents can take up significant resources and memory that can slow the response time of the application.

LINQ to XML is an interface supported in the WP7 (Windows Phone 7) for reading, editing, and deleting XML documents. This is similar to XML parsers. LINQ to XML is generally used for smaller documents.

XML is used indifferent ways in WP7 application development; here are a few scenarios:

  1. XAML is the XML format specific to the user interface. All the user elements are represented in the XML tags.
  2. XML is used for saving the settings or caching any information to local storage..
  3. Object serialization formats objects into an XML file.
  4. OData (Open Data Protocol), which is discussed in the Chapter 4, Using Open Data, returns the query results in XML format.
  5. REST (REpresentational State Transfer) web services return the data in XML format.
..................Content has been hidden....................

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