XML overview 3

Source: Internet
Author: User

 

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.