O'Reilly logo

Programming C# 3.0, 5th Edition by Donald Xie, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 14. Working with XML

XML, or eXtensible Markup Language, provides an industry-standard method for encoding information so that it is easily understandable by different software applications. It contains data and the description of data, which enables software applications to interpret and process that data.

XML specifications are defined and maintained by the World Wide Web Consortium (W3C). The latest version is XML 1.1 (Second Edition). However, XML 1.0 (currently in its fourth edition) is the most popular version, and is supported by all XML parsers. W3C states that:

You are encouraged to create or generate XML 1.0 documents if you do not need the new features in XML 1.1; XML Parsers are expected to understand both XML 1.0 and XML 1.1.[16]

This chapter will introduce XML 1.0 only, and in fact, will focus on just the most commonly used XML features. I'll introduce you to the XMLDocument and XMLElement classes first, and you'll learn how to create and manipulate XML documents.

Of course, once you have a large document, you'll want to be able to find substrings, and I'll show you two different ways to do that, using XPath and XPath Navigator. XML also forms a key component of the Service Oriented Architecture (SOA), which allows you to access remote objects across applications and platforms. The .NET Framework allows you to serialize your objects as XML, and deserialize them at their destination. I'll cover those methods at the end of the chapter.

XML Basics (A Quick Review) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required