Detailed explanation of XML syntax

Detailed explanation of XML syntax
1. Documentation Rules

1. Case sensitive.

2. The attribute value must be enclosed in quotes (either single quotes or double quotes). In general, double quotes are recommended.

3. All tags must have an end symbol.

4. All empty tags must be closed.

5. There must be one and only one element.

6. When parsing blank characters, the actual content will be output without abbreviation.

7. Special character processing:
Character replacement character
< &lt;
> >
& &amp;
" &quto;
' &apos;

8. Tag name conventions:
a.Can contain letters, numbers, and other characters.
b. It cannot start with a number or an underscore.
c. It cannot start with characters such as xml or Xml.
d. Cannot contain spaces


2. XML declaration

XML declaration standard statement: <?xml version="1.0" encoding="GB2312" standalone="yes"?>
emphasize:
1. There should be no space between "<?" and "xml" in "<?xml".
2. There can be a space before "?>" or not.
3. encoding and standalone are optional attributes. The default value of encoding is "UTF-8" and the default value of standalone is "no".
4. Common encoding methods are:
Simplified Chinese: GB2312
Traditional Chinese: BIG5
Western European characters: UTF-8,UTF-16
5.standalone indicates whether the document is accompanied by a DTD file.

3. XML attributes

Because data can be stored in both sub-elements and attributes, there is no fixed rule as to when to use attributes and when to use sub-elements, but it is recommended that metadata should be stored as attributes, while the data itself should be stored as elements.
Using attributes raises the following questions:
1. Attributes cannot contain multiple values ​​(sub-elements can).
2. Attributes are not easy to expand.
3. Attributes cannot describe structure (sub-elements can).
4. Attributes are difficult to test via DTD.

4. Namespace

There are two ways to declare a namespace:
1. By default, all elements do not need to specify a prefix, such as:
<schema xmlns="http://www.w3.org/2001/XMLschema">
<element name="diguonianzhu" type="string"/>

</schema>
2. Clearly declare that the xmlns keyword is associated with a namespace URI prefix, and all elements need to specify a prefix, such as:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLschema">
<xsd:element name="diguonianzhu" type="string"/>

<xsd:/schema>
Emphasize: The URI used to represent the namespace is not called by the XML parser, and the URI is not actually accessed. It just represents an identification name.

5. XML-specific tags: CDATA

The full name of CDATA is Character DATA, which is character data. It is mainly used to display special characters, such as "<".
The syntax of CDATA is:
<![CDATA[characters to be displayed]]> For example:
<?xml version="1.0"?>
<data>
<![CDATA[
<ok alma!> by a&b!

]]>
</data>
Emphasis: CDATA cannot be nested; the characters to be displayed cannot contain "]]>".

<<:  Web Design Tutorial (4): About Materials and Expressions

>>:  CSS solution for centering elements with variable width and height

Recommend

Introduction to new features of MySQL 8.0.11

MySQL 8.0 for Windows v8.0.11 official free versi...

LINUX Checks whether the port is occupied

I have never been able to figure out whether the ...

Detailed use cases of vue3 teleport

Official Website https://cli.vuejs.org/en/guide/ ...

Solution to MySQL connection exception and error 10061

MySQL is a relational database management system ...

Common rule priority issues of Nginx location

Table of contents 1. Location / Matching 2. Locat...

Detailed introduction and usage examples of map tag parameters

Map tags must appear in pairs, i.e. <map> .....

Solve the problem that Mysql5.7.17 fails to install and start under Windows

Install MySQL for the first time on your machine....

mysql 8.0.16 winx64.zip installation and configuration method graphic tutorial

This article shares the specific code of MySQL 8....

Solution to Chinese garbled characters when operating MySQL database in CMD

I searched on Baidu. . Some people say to use the...

Detailed explanation of the syntax and process of executing MySQL transactions

Abstract: MySQL provides a variety of storage eng...

11 Linux KDE applications you didn't know about

KDE Abbreviation for Kool Desktop Environment. A ...

Why does MySQL paging become slower and slower when using limit?

Table of contents 1. Test experiment 2. Performan...

Detailed explanation of basic operation commands for Linux network settings

Table of contents View network configuration View...

A brief discussion on MySQL select optimization solution

Table of contents Examples from real life Slow qu...

Summary of Binlog usage of MySQL database (must read)

I won't go into details about how important b...