Checkout corresponds to checkin, and export corresponds to import. In XML, some characters in checkout have special meanings. If you place the & quot; & lt; & quot; character in the XML element, an error occurs because the parser starts to treat it as a new element. XML errors will occur:
Entity reference
In XML, some characters have special meanings.
If you put the character "<" in an XML element, an error occurs because the parser starts to treat it as a new element.
XML errors will occur:
if salary < 1000 then
To avoid this error, useEntity referenceTo replace the "<" character:
if salary < 1000 then
In XML, there are 5 predefined entity references:
< |
< |
Less |
> |
> |
Greater |
& |
& |
And number |
' |
' |
Single quotes |
" |
" |
Quotation marks |
Note: in XML, only the characters "<" and "&" are indeed invalid. It is a good habit to replace it with entity references.
Annotations in XML
The syntax for writing comments in XML is similar to that in HTML:
In XML, spaces are retained
HTML truncates (Merges) multiple consecutive space characters into one:
HTML: Hello my name is David. output: Hello my name is David.
In XML, spaces in the document are not deleted.
XML naming rules
XML elements must follow the following naming rules:
The name can contain letters, numbers, and other characters.
The name cannot start with a number or punctuation.
The name cannot start with the character "xml" (or XML or Xml ).
The name cannot contain spaces.
You can use any name without reserved words.
Best naming convention
Make the name descriptive. The underlined name is also good.
The name should be brief, for example: Instead: .
Avoid "-" characters. If you name it in this way: "first-name", some software will think that you need to extract the first word.
Avoid "." characters. If you name "first. name" in this way, some software considers "name" as the attribute of the object "first.
Avoid ":" characters. The colon is converted to a namespace (described later ).
XML documents often have a corresponding database, where fields correspond to elements in XML documents. There is a practical experience, that is, using database naming rules to name elements in XML documents.
Non-English letters such as équáá are also legal XML element names, but you need to pay attention to problems that may occur when software developers do not support these characters.
The above is the content of XML entity reference, comments, and naming rules. For more information, see PHP Chinese website (www.php1.cn )!