XML sequence: (1) XML syntax

Source: Internet
Author: User
Tags xml parser


The XML file ends with an. xml suffix name.

XML files need to be parsed using an XML parser. The browser has a built-in XML parser.

If XML does not specify encoding, then the browser is parsed by default with UTF-8 encoding

1. Label

Syntax: <student></student> start tag tag body content end Tag

Attention:

1) <student/> or <student></student> empty label. No tag body content

2) XML tag names are case-sensitive.

3) XML tags must be paired correctly.

4) cannot use spaces between XML tag names

5) XML tag name cannot start with a number

6) in an XML document, there is only one root tag

2. Properties

Syntax: <student name= "Eric" >student</Student>

Attention:

1) attribute values must be enclosed in quotation marks, cannot be omitted, and cannot be mixed with single and double quotes!!!

2) A tag can have multiple properties, but not duplicate property names!!!

3. Comments

Syntax:<!--XML Comment--


4. Document Declaration

Syntax: <?xml version= "1.0" encoding= "Utf-8"?>

Version number of the Version:xml

Encoding: Code table to query when parsing XML file (code table when decoding process)

Attention:

1) If the XML file is developed in the Ecplise tool, the file is saved automatically according to the encoding of the document declaration when the XML file is saved.

2) If you modify the XML file with the Notepad tool, keep in mind that the XML file is saved according to the Encoding Code table declared by the document.

5. Escape character

Some special characters are built into the XML, and these special characters cannot be exported directly from the browser. If you want to export these special characters to the browser as they are, escape these special characters. The character after escaping is called an escape byte.


Escape character
Special Characters Escape Character
< &lt;
> &gt;
" &quot;
& &amp;
Space &nsbp;



6. CDATA Zone

Function: You can have some content that requires special characters to be uniformly output as-is.


7. Processing instructions

Role: Telling XML parsing if parsing an XML document



XML sequence: (1) XML syntax

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.