15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

904 ❘ ChaPTer 33 mAnipulAtinG xml<br />

<strong>and</strong> nodes, <strong>and</strong> you should also know what we mean when we refer to a well - formed document. You should<br />

also be familiar with SAX <strong>and</strong> DOM.<br />

If you want to learn more about XML, Wrox’s Professional XML (Wiley Publishing,<br />

2007, ISBN 978-0471-77777-9) is a great place to start.<br />

In addition to general XML usage, the .<strong>NET</strong> Framework also includes the ability to work with XML by<br />

using LINQ to XML. One of the available web downloads, Chapter 56, “ LINQ to SQL, ” takes a look<br />

at using LINQ to query SQL Server databases. This chapter takes a quick look at using LINQ to query your<br />

XML data sources instead.<br />

The discussion begins with a brief overview of the current status of XML st<strong>and</strong>ards.<br />

Xml sT<strong>and</strong>ards suPPorT in . neT<br />

The World Wide Web Consortium (W3C) has developed a set of st<strong>and</strong>ards that give XML its power <strong>and</strong><br />

potential. Without these st<strong>and</strong>ards, XML would not have the impact on the development world that it does.<br />

The W3C web site ( www.w3.org ) is a valuable source for all things XML.<br />

The .<strong>NET</strong> Framework supports the following W3C st<strong>and</strong>ards:<br />

➤<br />

➤<br />

XML 1.0 ( www.w3.org/TR/1998/REC - xml - 19980210 ), including DTD support<br />

XML namespaces ( www.w3.org/TR/REC - xml - names ), both stream level <strong>and</strong> DOM<br />

➤ XML schemas ( www.w3.org/2001/XMLSchema )<br />

➤ XPath expressions ( www.w3.org/TR/xpath )<br />

➤ XSLT transformations ( www.w3.org/TR/xslt )<br />

➤ DOM Level 1 Core ( www.w3.org/TR/REC - DOM - Level - 1 )<br />

➤ DOM Level 2 Core ( www.w3.org/TR/DOM - Level - 2 - Core )<br />

➤ SOAP 1.1 ( www.w3.org/TR/SOAP )<br />

The level of st<strong>and</strong>ards support will change as the framework matures <strong>and</strong> the W3C updates the<br />

recommended st<strong>and</strong>ards. Because of this, you need to make sure that you stay up to date with the st<strong>and</strong>ards<br />

<strong>and</strong> the level of support provided by Microsoft.<br />

inTroduCing The sysTem.Xml namesPaCe<br />

Support for processing XML is provided by the classes in the System.Xml namespace in .<strong>NET</strong>. This section<br />

looks (in no particular order) at some of the more important classes that the System.Xml namespace<br />

provides. The following table lists the main XML reader <strong>and</strong> writer classes.<br />

Class name<br />

XmlReader<br />

XmlWriter<br />

XmlTextReader<br />

XmlTextWriter<br />

desCriPTion<br />

An abstract reader class that provides fast, noncached XML data. XmlReader is forwardonly,<br />

like the SAX parser.<br />

An abstract writer class that provides fast, noncached XML data in stream or fi le format.<br />

Extends XmlReader. Provides fast forward-only stream access to XML data.<br />

Extends XmlWriter. Fast forward-only generation of XML streams.<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!