.NET XML Architecture


.NET contains an entire XML framework. This framework is made up of several classes that make it easy for you to implement and work with XML in your applications. Because .NET is so reliant on XML, Microsoft spent a great deal of time making these classes robust, easy to use, and very performant. As I have said before, these classes all follow the W3C specification for XML and they are an evolution to MSXML, which you might have already used.

Much of .NET actually uses XML for its native data representation. Examples of this can be seen in ASP.NET, Web services (which rely on the Simple Object Access Protocol, or SOAP), and you can even see XML in the automatic source code comments that are added when you create classes with Visual Studio.NET. XML is also an integral part of ADO.NET and SQL Server 2000, both of which are discussed in detail in Chapter 10.

The .NET XML classes enable you to easily work with relational data and hierarchical data. The classes provide a unified programming model.


The .NET XML framework can be found in several namespaces. The core types are contained in System.XML. The XPath and XSLT types can be found in System.Xml.XPath and System.Xml.Xsl. To use these classes you must import the correct names spaces through the using directive as follows :

 using System.Xml; 

At the core of the .NET framework XML classes are two abstract classes: XmlReader and XmlWriter . XmlReader provides a fast, forward-only, read-only cursor for processing an XML document stream. XmlWriter provides an interface for producing XML document streams that conform to the W3C's XML recommendations. Applications that need to process XML documents use XmlReader , whereas applications that want to create XML documents use XmlWriter . Both classes imply a streaming model that doesn't require an expensive in-memory cache. This makes them both attractive alternatives to the classic Document Object Model (DOM) approach.

The XmlReader and XmlWriter classes are abstract base classes. They define functionality that all derived classes must support. At present, three implementations of XmlReader are included in the .NET framework: XmlTextReader , XmlNodeReader , and XmlReader . Two implementations of XmlWriter are in the .NET framework. They are XmlTextWriter and XmlNodeWriter . The XmlTextReader and XmlTextWriter classes support reading from and writing to text-based streams. XmlNodeReader and XmlNodeWriter are used for in-memory DOM trees. One of the biggest advantages of this design is that custom readers and writers can be developed to extend the built-in functionality. I expect to see many of these extended classes appear on the Internet and in newsgroups as developers extend the classes to meet their needs and share the classes with others.


Special Edition Using ASP. NET
Special Edition Using ASP.Net
ISBN: 0789725606
EAN: 2147483647
Year: 2002
Pages: 233

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net