Xml 简明教程

XML - Overview

XML 代表 *E*xtensible *M*arkup *L*anguage。它是一种基于文本的标记语言,源自标准通用标记语言 (SGML)。

XML stands for *E*xtensible *M*arkup *L*anguage. It is a text-based markup language derived from Standard Generalized Markup Language (SGML).

XML 标签标识数据,用于存储和组织数据,而不是像用于显示数据的 HTML 标签那样指定如何显示数据。XML 在可预见的未来不会取代 HTML,但它通过采用 HTML 的许多成功功能引入了新的可能性。

XML tags identify the data and are used to store and organize the data, rather than specifying how to display it like HTML tags, which are used to display the data. XML is not going to replace HTML in the near future, but it introduces new possibilities by adopting many successful features of HTML.

XML 有三个重要的特性,使其在各种系统和解决方案中很有用:

There are three important characteristics of XML that make it useful in a variety of systems and solutions −

  1. XML is extensible − XML allows you to create your own self-descriptive tags, or language, that suits your application.

  2. XML carries the data, does not present it − XML allows you to store the data irrespective of how it will be presented.

  3. XML is a public standard − XML was developed by an organization called the World Wide Web Consortium (W3C) and is available as an open standard.

XML Usage

XML 用途的简短列表说明了一切:

A short list of XML usage says it all −

  1. XML can work behind the scene to simplify the creation of HTML documents for large web sites.

  2. XML can be used to exchange the information between organizations and systems.

  3. XML can be used for offloading and reloading of databases.

  4. XML can be used to store and arrange the data, which can customize your data handling needs.

  5. XML can easily be merged with style sheets to create almost any desired output.

  6. Virtually, any type of data can be expressed as an XML document.

What is Markup?

XML 是一种标记语言,它为以人类可读和机器可读格式编码文档定义了一组规则。那么什么是标记语言呢?标记是添加到文档中的信息,通过识别各个部分及其相互关系,可以以某种方式增强其含义。更具体地说,标记语言是一组符号,可以放在文档文本中,以划分和标记文档的部分。

XML is a markup language that defines set of rules for encoding documents in a format that is both human-readable and machine-readable. So what exactly is a markup language? Markup is information added to a document that enhances its meaning in certain ways, in that it identifies the parts and how they relate to each other. More specifically, a markup language is a set of symbols that can be placed in the text of a document to demarcate and label the parts of that document.

以下示例展示了当 XML 标记嵌入在文本片段中时的外观 −

Following example shows how XML markup looks, when embedded in a piece of text −

<message>
   <text>Hello, world!</text>
</message>

此代码段包括标记符号,或标记,如 <message>…​</message> 和 <text>…​ </text>。标记 <message> 和 </message> 标记 XML 代码片段的开始和结束。标记 <text> 和 </text> 环绕文本 Hello, world!。

This snippet includes the markup symbols, or the tags such as <message>…​</message> and <text>…​ </text>. The tags <message> and </message> mark the start and the end of the XML code fragment. The tags <text> and </text> surround the text Hello, world!.

Is XML a Programming Language?

编程语言由语法规则和自己的词汇组成,用于创建计算机程序。这些程序指示计算机执行特定任务。XML 没有资格成为编程语言,因为它不执行任何计算或算法。它通常存储在简单的文本文件中,并且由能够解释 XML 的特殊软件进行处理。

A programming language consists of grammar rules and its own vocabulary which is used to create computer programs. These programs instruct the computer to perform specific tasks. XML does not qualify to be a programming language as it does not perform any computation or algorithms. It is usually stored in a simple text file and is processed by special software that is capable of interpreting XML.