Basic XML knowledge, basic xml tutorial
An XML file usually contains the following parts:
1. Declaration section of the document.
This part declares the xml document version and its encoding method.
For example:
<? xml version="1.0" encoding="gbk"?>
2. Elements
The so-called elements can be understood as labels in xml.
The label naming requirements are as follows:
1. The element name cannot start with a number.
2. The element name cannot start with xml.
3. The element name cannot contain spaces or colons.
There are two types of elements:
1. The start tag and end tag exist. For example, <person> </person>
2. The start tag and end tag are in the same TAG body. Example: <br/>
3. Attributes
You can define attributes in a tag. For example, <person id = "123"> <person>
4. Special characters
Some special characters cannot appear in the label body. When encountering these characters, we need to use entity characters.
For example, for greater than and less than signs, xml will regard them as tags during parsing, and then the parsing may fail. Therefore, we should use entity characters to represent these characters.
5. Character Area
If we need to use a large number of special characters in a text, it is too much trouble to use entity characters to represent these special characters and it is not easy to read. In this case, we can use the character area, the text in the character area will be considered as common text by the parser and will not parse them. Usage:
<! [CDATA [character area content]>
6. processing commands
The Processing Command is to notify the xml interpreter how to process the xml file.
The following is an example of parsing xml files using CSS styles:
Processing Instruction format:
<? Xml-stylesheet type = "text/css" href = "a.css"?>