Unlike HTML, XML has a strict accordance with the syntax, and only the handler can analyze and process it only when an XML document meets the basic requirements of "format". "Good format" This standard is based on the grammatical provisions of the various logical components and physical components of the XML document, ensuring XML strict conditional, logical and good structural, which greatly improves XML application handler processing XML data. Accuracy and efficiency. In fact, the format has a good demand is the grammar requirements of the XML specification. A simple inspection method is to open the XML document you are editing with Internet Explorer4.01. If an error is reported, this document is not "well".
---- The structure of the XML document includes logical structures and physical structures.
First, logical structure
---- An XML document typically begins with an XML declaration to organize XML data through an XML element. The XML element includes tag and character data. In order to organize data more convenient, clear, you can also introduce a CDATA data block in character data, and you can introduce a comment in the document. In addition, the XML document can be included in the XML document since sometimes need to provide some instructions for the XML handler. Specifically, the role and form of each logic element is as follows:
---- 1. XML declaration
---- XML declaration is one of the processing instructions, and an XML document is best begins with an XML declaration. Here is a complete XML declaration:
XML Version = "1.0" encoding = "GB2312" Standalone = "no"?>
---- You must include a Version property in an XML processing instruction, indicating the version number of the XML used, and it must be ranked first in the attribute list. The Standalone property indicates whether the XML document is used to define DTD supporting using an external document type. The encoding property indicates the encoding standard used by the data. ----2. Elements --- element is the basic unit of XML document content. From the grammar, an element contains a starting mark, an end tag, and the data content between the tag. The form is:
Data Content Mark>
---- For markers, there is the following syntax: ---- (1) marking is essential. There is at least one element in any format in the XML document. ---- (2) Location. ---- (3) There is a correct end tag. End Mark In addition to the starting mark, you must add a slash "/" in front of the spelling and case. When there is no text content between a pair of tags, it may be not written without writing, and the final tag is confirmed by the slash "/". Such a flag is called "empty mark". ---- (4) Mark to nescery correctly. ---- (5) Tag naming should legal. The tagname should start with letters, underscore "_" or colon: "start, followed by letters, numbers, numbers". ", Colon, underscore or even characters" - ", but there is no space in the middle, and any tagname cannot be Any combination of "XML" (or "XML" case, such as "XML", "XML", "XML", etc.). ---- (6) Effective use attributes. The tag can contain any multiple properties, the attribute appears in name / value, the attribute name cannot be repeated, the name is separated by the equal sign "=" between the name and the value, and the value is caused by quotation marks. ---- 3. CDATA section ---- In tag CDATA, all tags, entity references are ignored, and the XML handler is treated as character data as a character data. The form of CDATA is as follows:
String "]]>" in the text content of CDATA, in addition, CDATA cannot nested, ---- 4. Note ---- Sometimes, people want to add some character data to the XML document and want the XML processor to do not process them. This type of text is called a comment text. In XML, the method of comment is identical to HTML, and the comment text is caused by "". There is also the following provisions for comments: ---- (1) Do not appear in the comment text "---- (2) Do not put the comment text in the mark, similarly Do not put the comment text in the entity statement or before. ---- (3) Note cannot be nested. ---- 5. Processing instruction PI ---- Processing command is used to provide information to the application of the XML document, the XML analyzer is not transmitted to the application, and the application interprets this instruction, follows it provides Information is processed. Processing instructions should follow the format below:
Processing instruction name processing instruction information>
---- The following is an example, it is an XML document describing dictionary:
[1] Xml version = "1.0" encoding = "gb2312" standalone = "no"?> [2] XML-stylesheet type = "text / xsl" href = "mystyle.xsl"?> [3]
Type Universal Entity Parameter Entity Use Operation In the XML document only in the DTD in DTD in DTD, "Text Content"> External Reference Way & Entity Name;% Entity Name; The Unit Entity of Describe the unit address is defined in the following example:
---- You can use this entity as follows in the XML file:
An external entity cannot be referenced in the tag properties. The character "<" cannot appear in the text, otherwise it is no longer a "well" XML file after the replacement.
Online Series Publications Computer World Microcomputer World IT Manager World Household Computer World Digital Wealth