Επεξεργασία

Κοινή χρήση μέσω


XML Documents and Data

.NET provides a comprehensive and integrated set of classes that enable you to build XML-aware apps easily. The classes in the following namespaces support parsing and writing XML, editing XML data in memory, data validation, and XSLT transformation.

For a full list, search for "System.Xml" on the .NET API browser.

The classes in these namespaces support World Wide Web Consortium (W3C) recommendations. For example:

The XML classes in the .NET Framework provide these benefits:

  • Productivity. LINQ to XML (C#) and LINQ to XML (Visual Basic) makes it easier to program with XML and provides a query experience that is similar to SQL.

  • Extensibility. The XML classes in the .NET Framework are extensible through the use of abstract base classes and virtual methods. For example, you can create a derived class of the XmlUrlResolver class that stores the cache stream to the local disk.

  • Pluggable architecture. The .NET Framework provides an architecture in which components can utilize one another, and data can be streamed between components. For example, a data store, such as an XPathDocument or XmlDocument object, can be transformed with the XslCompiledTransform class, and the output can then be streamed either into another store or returned as a stream from a web service.

  • Performance. For better app performance, some of the XML classes in the .NET Framework support a streaming-based model with the following characteristics:

    • Minimal caching for forward-only, pull-model parsing (XmlReader).

    • Forward-only validation (XmlReader).

    • Cursor style navigation that minimizes node creation to a single virtual node while providing random access to the document (XPathNavigator).

    For better performance whenever XSLT processing is required, you can use the XPathDocument class, which is an optimized, read-only store for XPath queries designed to work efficiently with the XslCompiledTransform class.

  • Integration with ADO.NET. The XML classes and ADO.NET are tightly integrated to bring together relational data and XML. The DataSet class is an in-memory cache of data retrieved from a database. The DataSet class has the ability to read and write XML by using the XmlReader and XmlWriter classes, to persist its internal relational schema structure as XML schemas (XSD), and to infer the schema structure of an XML document.

In This Section

XML Processing Options Discusses options for processing XML data.

Processing XML Data In-Memory Discusses the three models for processing XML data in-memory: LINQ to XML (C#) and LINQ to XML (Visual Basic), the XmlDocument class (based on the W3C Document Object Model), and the XPathDocument class (based on the XPath data model).

XSLT Transformations
Describes how to use the XSLT processor.

XML Schema Object Model (SOM)
Describes the classes used for building and manipulating XML Schemas (XSD) by providing an XmlSchema class to load and edit a schema.

XML Integration with Relational Data and ADO.NET
Describes how the .NET Framework enables real-time, synchronous access to both the relational and hierarchical representations of data through the DataSet object and the XmlDataDocument object.

Managing Namespaces in an XML Document
Describes how the XmlNamespaceManager class is used to store and maintain namespace information.

Type Support in the System.Xml Classes
Describes how XML data types map to CLR types, how to convert XML data types, and other type support features in the System.Xml classes.

ADO.NET
Provides information on how to access data using ADO.NET.

Security
Provides an overview of the .NET Framework security system.