XML概念解释
XML概念解释
概念:可扩展标记语言(英语:Extensible MarkupLanguage,简称:XML),
是一种标记语言。标记指计算机所能理解的信息符号,通过此种标记,计算机之间可以处理包含各种信息的文章等。
如何定义这些标记既可以选择国际通用的标记语言,比如HTML,也可以使用像XML这样由相关人士自由决定的标记语言,这就是语言的可扩展性。
XML是从标准通用标记语言(SGML)中简化修改出来的。
在电子计算机中,标记指计算机所能理解的信息符号,通过此种标记,计算机之间可以处理包含各种的信息比如文章等。它可以用来标记数据、定义数据类型,是一种允许用户对自己的标记语言进行定义的源语言。 它非常适合万维网传输,提供统一的方法来描述和交换独立于应用程序或供应商的结构化数据。是Internet环境中跨平台的、依赖于内容的技术,也是当今处理分布式结构信息的有效工具。早在1998年,W3C就发布了XML1.0规范,使用它来简化Internet的文档信息传输。
What is XML ?
Extensible Markup Language (XML) is a type of markup language that establishes a set of guidelines for encoding texts in a way that is both machine- and human-readable. For storing and transferring data on the web and in many other applications, XML is widely used. XML steps in as a versatile tool for encoding and organizing data in a way that both humans and machines can comprehend.
History of XML
XML emerged in the late 1990s as a revolutionary concept in the evolving landscape of the internet. Before XML, HTML served as the predominant language for web content, but it lacked the flexibility needed for complex data representation. XML arrived as a solution, offering a standardized format for expressing diverse types of data in a hierarchical structure.
Different ways of using XML
In the realm of XML, everything revolves around tags. Think of tags as containers that hold different pieces of information. Each tag has a name and can optionally carry attributes, providing additional details about the enclosed data. Here’s a simple breakdown:
<element attribute="value">Text content</element>
Let’s unpack this: <element> represents the name of the container, attribute is like a label describing the container’s contents, and Text content is the actual information stored within the container.
Simple XML Document
<book> acts as the main container, housing details about a book such as its title, author, and publication year.
Example:
<book>
<title>Harry Potter and the Sorcerer's Stone</title>
<author>J.K. Rowling</author>
<year>1997</year>
</book>
XML with Attributes
Here, <student> serves as the container for student information, with attributes like id providing additional identifiers.
Example:
<student id="001">
<name>John Doe</name>
<age>25</age>
<grade>A</grade>
</student>
Example: the <book> element serves as the primary container, encompassing information pertaining to a book such as its title, author, and year of publication.