Home > Article > Web Front-end > Detailed explanation of xml syntax_HTML/Xhtml_Web page production
1. Document rules
1. Case sensitive.
2. Attribute values must be enclosed in quotation marks (either single quotation marks or double quotation marks are acceptable). In general, it is recommended to use double quotation marks.
3. All tags must have a closing 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 and will not be abbreviated.
7. Special character processing:
character replacement character
& &
" &quto; 🎜>8. Tag name convention:
a. Can contain letters, numbers, and other characters.
b. Cannot start with numbers and underscores.
c. Cannot start with characters such as xml or Xml.
d. Cannot contain spaces
2. XML declaration
xml declaration standard statement:
Emphasis:
1. "2. There may or may not be a space before "?>".
3. Enconding and standalone are optional attributes, and the default value of encoding is. "UTF-8", standalone default value 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 comes with a DTD file
3. xml attributes
Because data can be stored in child elements or attributes, when There are no fixed rules for when to use attributes, but it is recommended that metadata should be stored as attributes, and the data itself should be stored as elements.
Using attributes will cause the following problems:
1. Attributes cannot contain multiple values (child elements can).
2. Attributes cannot be easily extended.
3. Attributes cannot describe structures (child elements can).
4. Attributes are difficult to test via DTD.
4. Namespace
Two ways to declare a namespace:
1. Default declaration, all elements do not need to specify prefixes, such as:
2. Clearly state that the xmlns keyword is associated with the prefix of a namespace URI, and all elements need to specify the prefix, such as:
5. XML-specific tags: CDATA
The full name of CDATA is Character Data, which is mainly used to display special characters, such as "
For example:
by a&b!
] ]>
Emphasis: CDATA cannot be nested; the characters to be displayed cannot contain "]]>".