Invalid, valid, and well-formatted documents
There are three types of XML documents:
Invalid document: does not comply with the syntax rules defined in the XML specification. If a developer has defined what a document can contain in a DTD or mode and a document does not comply with those rules, this document is also invalid.
Valid document: comply with XML syntax rules and rules defined in their DTD or schema.
Well-formatted documents: Follow the XML syntax, but there is no DTD or mode.
Complete XML documents:
XML documents that comply with the following rules are called structured integrity:
-XML declaration statements must be available.
<? XML version = "1.0" encoding = "GBK"?>
-It must have only one root element.
-Mark case sensitive
-Attribute values are enclosed in quotation marks.
-Paired
-Disable empty tag
-Correct element nesting
Element Syntax:
-The name can contain letters, numbers, or other characters.
-The name cannot start with a number or a hyphen (-).
-Cannot start with XML
-The name cannot contain spaces.
-Names cannot contain colons (colons are reserved for namespaces)
XML document Rule Summary :-
-XML documents generally start with an XML declaration.
-XML elements include tag and character data
-Organize XML data through XML elements
-CDATA is introduced into character data for easier and clearer organization data
-Add comments to the document
-Instructions must be provided to the XML processing program. XML documents can contain processing commands.
Entity reference example:
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE hotelList [
<! ENTITY g4 "four-star">
<! ENTITY g5 "five-star">
]>
<HotelList>
<Hotel>
<Name> Sihai hotel </name>
<Address> haimu Road 1 </Address>
<HomePage> www.sihaohote.com.cn </HomePage>
<E-mail> mater@sihaototel.com.cn </E-mail>
<TelePhone> 23423423423 </TelePhone>
<Grade> & g4; </Grade>
</Hotel>
<Hotel>
<Name> Wuhu hotel </name>
<Address> No. 99 Dongping road </Address>
<HomePage> www.wuhu.com.cn </HomePage>
<E-mail> web@wuhu.com.cn </E-mail>
<TelePhone> 4545454 </TelePhone>
<Grade> & g5; </Grade>
</Hotel>
</HotelList>