First, document rules
1. Case sensitive.
2. Attribute values must be enclosed in quotation marks (both single and double quotes) and are generally recommended for use with double quotes.
3. All tokens must have a closing symbol.
4. All empty tags must be closed.
5. Must have and only one element.
6. When parsing white space characters, it will be output according to the actual content, not abbreviated.
7. Special character Processing:
Character substitution character
< <
> >
& &
"&quto;
' '
8. Tag Name Convention:
A. Can contain letters, numbers, and other characters.
B. Cannot begin with numbers and underscores.
C. You cannot start with a character such as XML or XML.
D. Cannot contain spaces
Second, the XML declaration
XML declaration standard statement: <?xml version= "1.0" encoding= "GB2312" standalone= "yes"?>
Emphasize:
1. "<?xml" in "the" and "XML" cannot have spaces in between.
2. "?>" can be preceded by a space, or it may not be.
3.enconding and standalone are optional properties, encoding default is "UTF-8" and standalone default is "no".
4. Common coding methods are:
Simplified Chinese: GB2312
Traditional Chinese: BIG5
Western European character: Utf-8,utf-16
5.standalone Indicates whether the document comes with a DTD file.
Three, XML attributes
Because data can be stored either in child elements or in attributes, when attributes are used, when child elements are used, there is no fixed rule, but it is suggested that metadata should be stored as attributes and that the data itself should be stored as elements.
Using attributes raises the following issues:
1. Attributes cannot contain multiple values (child elements can).
2. Properties are not easy to expand.
3. Properties cannot describe structs (child elements can).
4. Attributes are difficult to test with DTDs.
Four, the name space
Declaring namespaces two ways:
1. Default declaration, 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. Explicitly declares that the xmlns keyword is associated with the prefix of a namespace's URI, and that 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>
Emphasis: The URI used to represent the namespace is not invoked by the XML parser and does not actually access the URI, it simply represents an identity name.
V. XML-specific Tags: CDATA
CDATA The full name is character data, which is mainly used to display special characters, such as "<".
CDATA The syntax format is:
<! [cdata[the character to be displayed]]> as:
<?xml version= "1.0"?>
<data>
<! [cdata[
<ok alma!> by a&b!
]]>
</data>
Emphasis: CDATA cannot be nested; the character to display cannot contain "]]>".