XML and .NET

One of the major features of the .NET Framework is that it enables you to easily produce distributed applications that are language-independent and that will be platform-independent when .NET is ported to other platforms. XML plays a major part in this plan by acting as a simple, portable glue layer that’s used to pass data around in distributed applications.

Microsoft has XML-enabled many parts of the .NET Framework, and I’ll list a few of the main ones to give you a flavor of where and how they are used:

  • It’s possible for the results of database queries to be returned as XML so that they are far more portable than ActiveX data object (ADO) recordset objects. It’s also possible to interact with databases more fully using XML.

  • Calls can be made to Web services using SOAP, an XML-based protocol for making remote procedure calls.

  • Finding out what a Web service provider can do for you involves using UDDI, the Universal Description, Discovery, and Integration service. When you query a UDDI service, you post a query in XML and a description of what is available comes back as more XML.

The .NET XML Namespaces

The .NET Framework contains a number of namespaces supporting XML functionality, as summarized in the following table.




The overall namespace for XML support


Support for the World Wide Web Consortium (W3C) and the Microsoft XML-Data Reduced (XDR) schemas


Supports serializing objects to and from XML


Supports XPath parsing and evaluation


Supports Extensible Stylesheet Language Transformations (XSLT)

This chapter will be mainly concerned with the System::Xml namespace and will touch on some of the capabilities of System::Xml::Schema. Chapter 21 will cover using the XPath and Xsl namespaces.

The XML Processing Classes

There are four main classes in the System::Xml namespace for processing XML. I’ll briefly list their capabilities and functionality here, before getting into more detailed examination in the rest of the chapter.

  • The XmlTextReader class is used for fast, forward-only parsing without validation. It will check that documents are well-formed using a Document Type Definition (DTD), but it doesn’t use the DTD for validatation. Forward-only parsing means that you parse the document from start to finish, and you can’t back up to reparse an earlier part of the document.

  • XmlValidatingReader implements a forward-only parser that provides more functionality than XmlTextReader, in particular, the ability to validate input using DTDs, W3C XML Schema Definition (XSD) schemas, or XDR schemas. Both XmlTextReader and XmlValidatingReader are derived from the abstract class XmlReader, which provides much of the basic functionality.

  • XmlTextWriter provides a fast, forward-only way to write XML to streams or files. The XML produced conforms to the W3C XML 1 specification, complete with namespace support.

  • XmlDocument implements the W3C Document Object Model (DOM), providing an in-memory representation of an XML document.

Microsoft Visual C++  .NET(c) Step by Step
Microsoft Visual C++ .NET(c) Step by Step
ISBN: 735615675
Year: 2003
Pages: 208

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