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

Rules for registration form design

I finished reading "Patterns for Sign Up &...

Mysql tree-structured database table design

Table of contents Preface 1. Basic Data 2. Inheri...

Comprehensive summary of Vue3.0's various listening methods

Table of contents Listener 1.watchEffect 2.watch ...

Detailed explanation of Docker container data volumes

What is Let’s first look at the concept of Docker...

CSS3 Tab animation example background switching dynamic effect

CSS 3 animation example - dynamic effect of Tab b...

How to operate MySql database with gorm

1. Setting case sensitivity of fields in the tabl...

Flame animation implemented with CSS3

Achieve results Implementation Code html <div ...

MySQL 8.0.15 installation tutorial for Windows 64-bit

First go to the official website to download and ...

MySQL single table query example detailed explanation

1. Prepare data The following operations will be ...

CSS implementation code for drawing triangles (border method)

1. Implement a simple triangle Using the border i...

Writing a rock-paper-scissors game in JavaScript

This article shares the specific code for writing...

Copy the contents of one file to the end of another file in linux

Problem description: For example, the content of ...