Chapter 10. Working with XML in .NET

 < Day Day Up > 

Topics in This Chapter

  • Introduction to Using XML: Introduces some of the basic concepts of working with XML. These include the XML validation and the use of an XML style sheet.

  • Reading XML Data: Explains how to use the .NET XML stack to access XML data. The XmlReader, XmlNodeReader, XmlTextReader are examined.

  • Writing XML Data: The easiest way to create XML data is to use the .NET XmlSerializer to serialize data into the XML format. When the data is not in a format that can be serialized, an alternative is the XmlWriter class.

  • Searching and Updating XML Documents: XPath is a query language to search XML documents. Examples illustrate how to use it to search an XmlDocument, XmlDataDocument, and XPathDocument.

Extensible Markup Language (XML) plays a key role in the .NET universe. Configuration files that govern an application or Web page's behavior are deployed in XML; objects are stored or streamed across the Internet by serializing them into an XML representation; Web Services intercommunication is based on XML; and as we see in Chapter 11, "ADO.NET," .NET methods support the interchange of data between an XML and relational data table format.

XML describes data as a combination of markup language and content that is analogous to the way HTML describes a Web page. Its flexibility permits it to easily represent flat, relational, or hierarchical data. To support one of its design goals that it "should be human-legible and reasonably clear"[1] it is represented in a text-only format. This gives it the significant advantage of being platform independent, which has made it the de facto standard for transmitting data over the Internet.

[1] W3C Extensible Markup Language (XML), 1.0 (Third Edition),

This chapter focuses on pure XML and the classes that reside in the System.Xml namespace hierarchy. It begins with basic background information on XML: how schemas are used to validate XML data and how style sheets are used to alter the way XML is displayed. The remaining sections present the .NET classes that are used to read, write, update, and search XML documents. If you are unfamiliar with .NET XML, you may surprised how quickly you become comfortable with reading and searching XML data. Extracting information from even a complex XML structure is refreshingly easy with the XPath query language and far less tedious than the original search techniques that required traversing each node of an XML tree. In many ways, it is now as easy to work with XML as it is to work with relational data.

     < Day Day Up > 

    Core C# and  .NET
    Core C# and .NET
    ISBN: 131472275
    EAN: N/A
    Year: 2005
    Pages: 219 © 2008-2017.
    If you may any questions please contact us: