A, XML , some introduction
XML (Extensible Markup Language) Extensible Markup Language, is a markup language. It is similar in writing the HTML , belonging SGML subset, it is inherited only SGML (Standard Generalized Markup Language ---- Standard Generalized Markup Language, is an indication tag or document set standard language standard ) custom tags advantages It has abandoned some of the SGML complex part, in function to complement HTML inadequate mark, with more scalability.
Two, XML component files
XML file is basically can be said by the tag, and content in XML constituent elements of the file can appear mainly There are six:
a) element ( the Element )
XML files are Russia, the elements of the XML sense elements and mark the representative is different:
Ø marker ( the Tag ): the XML can custom tag that identifies the part of the file
Ø elements ( Element ): XML elements as the main structure of the entire document, the elements themselves can be labeled or add text element contains other elements, the elements it is a complete project includes tags, attributes, marking the beginning and end text and end tags in the tag.
b) property ( the Attribute )
After marking the start tag name, the tag can add an attribute name for each attribute has an attribute name and value and required value quoted.
c) the entity reference ( the Entity Reference )
Markup Language itself has some reservations symbol, such as " < ", if the contents of the documents required to use these symbols need to use entity reference, the XML entities refer to five reserved in advance in the following table:
Entity Reference |
symbol |
< |
<
|
> |
>
|
& |
& |
' |
‘ |
"e; |
“ |
d) Notes ( commet )
And HTML comments as a "<! -" start and with "->" end
E) CDATA chunks ( CDATA Section ) given PCDATA
In XML text file is PCDATA , in dealing with XML elements title , the tag text is PCDATA
f) PI(Processing Instructions)
PI allows the XML file that contains the instructions for applications. Such as XML beginning of the declaration file is a PI , this information tell XML parser how to handle the XML file
PI format is "<? Name" start and with "?>" End, name is the "PI target " ( PI Target ) name
g) DTD(Document Type Declarations)
XML specification section belongs to a large DTD file verification command, which is SGML default file authentication, is also XML used in XML in addition to the elements of these elements is to check the file DTD
Three, XML declaration file
All XML files need a special code to declare the document as XML files, thus XML beginning of the file, we often see such a file declaration block:
<?xml version="1.0" encoding=" GB2312" standalone=”no”?>
Version : declare the XML version of the file
Encoding : declare the XML character set used in the file (here using the Simplified Chinese)
Standalone : declare the XML if the file as a separate file or whether to use an external DTD file ( yes said they did not use an external DTD file, NO indication that the property can be omitted.)
Four, XML grammar file
a) start and end of grammar
Ø Start tag:
<tag_name attribute_name =” vlaue” ……>
Here tag_name name tag, followed by its properties, the properties can not
Note: In XML case is a distinction, the tag name must be paired, as <a> ... </a>.
Ø End tag:
</tab_name
b) markup syntax element empty
If the start and end tags have no content, which we call empty element tag, empty tags, there are two writing:
Ø <tag_name />
Ø <tag_name> </tag_name>
c) element tagged Precautions
Ø nested XML elements not overlap
Such as: <a> <B> asdfsda </ B> </a> not written <a> <b> asdfsda </a> </ b>
Ø attribute value requires double quotes
Five, XML namespaces
Why introduce a namespace problem? We often encounter in the program have repeated question mark in a file, which is not even a mark and is in a different space, we use them to further identify the namespace. (Colloquial terms , in a XML file, we Node <EmployeeInfo> have at <address> node, while the node <Job> there at <address> node, two nodes may occur when the machine identification error, you can identify them effectively after the addition of the namespace)
a) the full name of the tag
< Namespace prefix : tag name >
Since the web site is unique, usually we will mark it as a namespace, we can use the urn namespace declaration.
b) default declaration
In the same XML within the range of elements in the default namespace declaration only need to name the root element declaration space, in the following format: xmlns : prefix = "uri"
In xmlns " : " after adding the prefix name, such as xmlns : Company = "http://www.haiye.com"
c) display statement
Because XML file elements belong to multiple namespaces, we can use the prefix name to display the statement
如: <company : Intorduce xmlns:company = http://www.haiye.com
xmlns: product = = http://www.haiyeMusic.com>
<Company : name> sea industry Shop </ Company : name>
< company :produceList>
<product:list >
<product: name> Haiye listening player <product: name>
<product:author> Steven <product:author >
<product: reason> have memories </ product: reason>
< /product: list >
< product:name>
< company :produceList>
<Company : address> Shanghai Pudong Zhangjiang </ Company : address>
</ company : Intorduce>
VI Conclusion
I want my XML can just touch on some of introduction and summary XML plays a reuse entry for beginners, there are talking about should be relatively easy to understand. In the future I will note XML that is currently widely used for in-depth presentation markup language, such as XML Schema , etc. as well as how to operate and use in the program XML to better serve our application or system service, in particular to make beginners from easy and difficult to grasp him.
Arranger: Steven
Time: 2007-4-7
Reproduced in: https: //www.cnblogs.com/shimeng3344518/archive/2007/04/07/StevenPei.html