XML- grammar (a)

【content】

1.XML statement

Most XML file with an XML declaration as the beginning, it provides basic information about the document. The syntax is as follows:

<?xml version="1.0" encoding="utf-8"?>

Where, version represents the version of XML, Encoding represent XML file character encoding method used.

2. Label

Text label is a left bracket (<) and a right bracket (>) between

Tag (eg: <name>)

End tag (eg: </ name>)

3. The root element

The structure of the XML document is a tree, it starts from the "roots", and then extended to "foliage"

XML content must be contained in a single element. This single element is called the root element, which contains all the text in the document and all other elements

XML document must have a root element.

4. elements

Element is the start tag, end tag and all the content is located between the two.

Elements are case-sensitive, and should be properly nested, XML elements must be properly closed.

E.g:

 

5. entity references

In order to avoid the character data and labels need to use some special symbols to be confused, XML entity references are also provided.

 

6. Properties

Must have a value attribute;

Those values ​​must be enclosed in quotes;

You can use single quotes, double quotes can also be used, but should always be consistent.

7.CDATA and Notes

Under special label CDATA, all the tags, entity references are ignored, XML processing program is equally treat data as a character.

CDATA form:

<! [CDATA [text]]>

In XML, the comment is "<! -" and "->" to the cause.

8. The processing instruction (PI)

Indicates that the current content of the XML file, how to be displayed or processed.

Syntax:

<?target arg*?>

For example: Using XSLT handle the current XML file

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

9.XML display

(1) XML directly displayed on a browser such as IE

 

(2) XML using XSLT the like in IE browser

 

10. Good XML format

Format Good (Well-formed)

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

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

格式良好的XML会遵守以下XML语法规则:

XML文件必须有根元素;

XML文件必须有关闭标签;

XML标记对大小写敏感;

XML元素必须被正确的嵌套;

XML属性必须加引号。

发布了116 篇原创文章 · 获赞 25 · 访问量 1万+

Guess you like

Origin blog.csdn.net/frj0260/article/details/104347600