Knowledge of XML

(I) The concept

What is XML?

⑴XML refers to the Extensible Markup Language (EXtensible Markup Language)

⑵XML is a markup language, much like HTML

⑶XML is designed to transmit data rather than displaying data

⑷XML predefined tag is not necessary to define their own tags.

⑸XML is designed to have self-descriptive.

⑹XML is a W3C Recommendation

 

The main difference with the HTML ㈡XML

⑴XML not an HTML alternative .

⑵XML and HTML designed for different purposes.

⑶XML is designed to transmit and store data, which is the focus of the content data.

⑷HTML was designed to display data, which is the focus of appearance data.

⑸HTML designed to display information, while XML is designed to transmit information.

 

XML does not replace HTML, XML is an HTML supplement . In most web applications, XML is used to transmit data, while HTML is used to format and display the data.

The best description of XML are: XML is independent of hardware, software and information transfer tools .

 

㈢XML use

⑴XML used in many aspects of the development of the web, often used to store and share data simplified.

 

 

 

⑵XML separating data from HTML:

By XML, data can be stored in a separate XML file. So you can concentrate on using HTML for layout and display, and be sure to change the underlying data is no longer required to make any changes to the HTML.

 

⑶XML simplify data sharing:

The computer system and the data in incompatible formats used to store data.

XML data in plain text stored format, there is provided a method of storing data independent of software and hardware.

 

㈣XML tree

⑴XML 文档必须包含根元素。该元素是所有其他元素的父元素

⑵XML 文档中的元素形成了一棵文档树。这棵树从根部开始,并扩展到树的最底端

⑶所有元素均可拥有子元素。

⑷父、子以及同胞等术语用于描述元素之间的关系。父元素拥有子元素。相同层级上的子元素成为同胞(兄弟或姐妹)。

⑸所有元素均可拥有文本内容和属性(类似 HTML 中)。

 

XML 语法规则

 

⑴所有 XML 元素都没有关闭标签。

⑵XML 标签对大小写敏感,XML 元素使用 XML 标签进行定义。必须使用相同的大小写来编写打开标签和关闭标签。

⑶XML 必须正确地嵌套。例如:由于 <i> 元素是在 <b> 元素内打开的,那么它必须在 <b> 元素内关闭。

⑷XML 文档必须有根元素。

XML 文档必须有一个元素是所有其他元素的父元素。该元素称为根元素。

⑸XML 的属性值须加引号。

实体引用。

如果你把字符 "<" 放在 XML 元素中,会发生错误,这是因为解析器会把它当作新元素的开始。

例如:这个样子就是错的:<message>if salary < 1000 then</message>

   用实体引用来代替 "<" 字符:这样就是对的:<message>if salary &lt; 1000 then</message>

 

㈥XML 元素

Ⅰ什么是 XML 元素?

XML 元素指的是从(且包括)开始标签直到(且包括)结束标签的部分。

元素可包含其他元素、文本或者两者的混合物。元素也可以拥有属性。

ⅡXML 命名规则

XML 元素必须遵循以下命名规则:

⑴名称可以含字母、数字以及其他的字符。

⑵名称不能以数字或者标点符号开始

⑶名称不能以字符 “xml”(或者 XML、Xml)开始。

⑷名称不能包含空格

 

ⅢXML 元素是可扩展

 

㈦XML 验证

拥有正确语法的 XML 被称为“形式良好”的 XML。

通过 DTD 验证的 XML 是“合法”的 XML。

 

参考:W3SCHOOL

         希望有所帮助.

Guess you like

Origin www.cnblogs.com/shihaiying/p/11299584.html