XML Technology Backgrounder
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

XML Technology Backgrounder

Visual Studio .NET 2003

Extensible Markup Language (XML) provides a way to describe structured data. Unlike HTML tags, which are primarily used to control the display and appearance of data, XML tags are used to define the structure and data types of the data itself.

XML uses a set of tags to delineate elements of data. Each element encapsulates a piece of data that may be very simple or very complex. You can define an unlimited set of XML tags. For example, you might define XML tags to declare pieces of data from a purchase order, such as the price, tax, shipping address, billing address, and so on. As XML tags are adopted throughout an organization and across organizations, data from all kinds of different data stores will be easier to exchange and manipulate.

XML is simple, platform-independent, and a widely adopted standard. The advantage of XML over HTML is that it separates the user interface from the structured data. This separation of data from presentation enables the integration of data from diverse sources. Customer information, purchase orders, research results, bill payments, medical records, catalog data, and other information can be converted to XML.

XML vs. HTML

The following are a few important points to keep in mind about the relationship between XML and HTML:

  • XML is not a replacement for HTML; in fact, XML can be considered a complement to HTML. XML and HTML have different goals: HTML is designed to display data and is focused on how data looks, while XML is designed to describe data and to focus on what data is.
  • Like HTML, XML does not do anything. While XML tags can be used to describe the structure of an item such as a purchase order, it does not contain any code that can be used to send that purchase order, process it, or ensure that it is filled. Other people must write code to actually do these things with your XML-formatted data.
  • Unlike HTML, XML tags are defined by the author of a schema or document and are unlimited. HTML tags are predefined; HTML authors can only use tags that are supported by the current HTML standard.

Uses of XML

XML is an extremely flexible way to pass around data. The following are all examples where XML can be used:

  • An ordinary document
  • A structured record, such as an appointment record or purchase order
  • Internet/intranet Web applications that move data
  • An object with data, such as the persistent format of an object or ActiveX control
  • A data record, such as the result set of a query
  • Meta-content about a Web site, such as Channel Definition Format (CDF)
  • Graphical presentation, such as an application's user interface
  • Links between information and people on the Web
  • C# code, which can be documented with XML; for more information, see XML Documentation
  • Discovery documents used to locate available XML Web services; For more information, see XML Web Service Discovery.

The following lists several advantages XML has over other formats when storing information:

  • XML formats are text-based, making them more readable, easier to document, and sometimes easier to debug.
  • XML documents can use much of the infrastructure already built for HTML, including the HTTP protocol and some browsers. HTTP allows XML to be transferred across firewalls.
  • XML parsing is well defined and widely implemented, making it possible to retrieve information from XML documents in a variety of environments.
  • Applications can rely on XML parsers to do some structural validation, as well as data type checking (when schemas are used).
  • XML is built on a Unicode foundation, making it easier to create internationalized documents.

XML is not appropriate for every situation, however. XML documents tend to be more verbose than the binary formats they replace. They take up more network bandwidth and storage space, or require more processor time for compression. XML parsing can be slower than parsing highly optimized binary formats and can require more memory. However, careful application design can avoid some of these problems.

Validating XML Documents

To validate that XML documents contain the desired data and structure, an XML Schema must be associated with the XML document. XML Schemas are the rules that define how elements and attributes are structured to form XML documents. You can share schemas between organizations to make it simple to transfer and process shared data. For more information, see Introduction to XML Schemas.

Displaying XML Data

There are several ways that can be used to display (or present) XML data.

There are even mechanisms of data binding that can be used along with style sheets to arrange XML data into a visual presentation and to add interactivity.

Among others, here are a few methods to display XML:

  • XSLT – Extensible Style Sheet Language
  • CSS – Cascading Style Sheets
  • Microsoft Internet Explorer

For more information, see MSDN Online XML Developer Center Web site (http://msdn.microsoft.com/xml/default.asp).

XML Resources

If you are familiar with HTML, you can learn to create XML documents, requiring only that they be valid and well formed. For more information about XML, see the XML SDK and MSDN Online XML Developer Center Web site (http://msdn.microsoft.com/xml/default.asp).

For more information, see the World Wide Web Consortium (W3C) Specification for XML (http://www.w3.org/XML/).

See Also

XML Schemas and Data | XML Schemas and the XML Designer| XML Elements, Attributes, and Types | XML in Visual Studio | XML Documentation | Introduction to Datasets | Introduction to Data Access with ADO.NET

Show:
© 2016 Microsoft