MDN wants to talk to developers like you:


Summary: This article introduces the 'eXtensible Markup Language' (XML) and tells of it's uses.XML是一种类似于HTML的标记语言。它代表可扩展标记语言并且是一个W3C推荐的规范作为一种通用标记语言。这意味着,与其他标记语言不同,XML未预定义,因此你必须定义自己的标记。该语言的主要目的是跨不同系统共享数据,如互联网。

有许多基于XML的语言;一些示例是  XHTMLMathMLSVGXULXBLRSS, 和 RDF。你也可以创建自己的。



XML, 就是 Extensible Markup Language(可扩展标记语言), 是 W3C 推荐参考 通用标记语言. XML 同样也是SGML的子类.

许多语言都是基于XML, 如 XHTML, MathML, SVG, XUL, RSS, 还有 RDF.



HTML 可以归结为以下三个方面:intelligence(智能),maintenance(可维护性),adaptation(适应性)。XML 也有类似的特性:intelligence, adaptation, maintenance, 和simplicity(简洁)。

XML 不同于HTML,HTML 是显示标记,而XML 是通用标记。这两点可以在XSLT中融合在一起。

"正确的" XML (有效且格式良好)

For an XML document to be correct it must be a well-formed document, conforming to all of XML's syntax rules, and valid, conforming to a specific language's rules. An example of a document that is not well formed is one with an element that has an opening tag with no closing tag and is not self-closing.


XML 示例

There are two different ways that XML can be used for presentation, and this can range from transforming to HTML, to creating PDF or image codes.

One way to have have a style on a XML page is to use CSS with the xml stylesheet declaration.

<?xml-stylesheet type="text/css" href="stylesheet.css"?>

Or with the powerful XSLT, which is capable of transforming XML markup into any number of things, the possibilities are almost endless.

<?xml-stylesheet type="text/xsl" href="transform.xsl"?>




Displaying XML

XML is usually used for descriptive purposes, but there are ways to display XML data. If you don't define a specific way for the XML to be rendered, the raw XML is displayed in the browser.

One way to style XML output is to specify CSS to apply to the document using the xml-stylesheet processing instruction.

<?xml-stylesheet type="text/css" href="stylesheet.css"?>

There is also another more powerful way to display XML: the Extensible Stylesheet Language Transformations (XSLT) which can be used to transform XML into other languages such as HTML. This makes XML incredibly versatile.

<?xml-stylesheet type="text/xsl" href="transform.xsl"?>


This article is obviously only a very brief introduction to what XML is, with a few small examples and references to get you started. For more details about XML, you should look around on the Web for more in-depth articles.

Learning the HyperText Markup Language (HTML) will help you better understand XML.

See also

The Using XML article above is a great resource on information for transforming and creating your own language.


 此页面的贡献者: xgqfrms-GitHub, Y001, Mgjbot, Gelihui, Kakurady, Dbseti
 最后编辑者: xgqfrms-GitHub,