Basic XML knowledge, basic xml tutorial

Source: Internet
Author: User

Basic XML knowledge, basic xml tutorial

An XML file usually contains the following parts:

1. Declaration section of the document.

This part declares the xml document version and its encoding method.

For example:

<? xml version="1.0" encoding="gbk"?>

2. Elements

The so-called elements can be understood as labels in xml.

The label naming requirements are as follows:

1. The element name cannot start with a number.

2. The element name cannot start with xml.

3. The element name cannot contain spaces or colons.

There are two types of elements:

1. The start tag and end tag exist. For example, <person> </person>

2. The start tag and end tag are in the same TAG body. Example: <br/>

 

3. Attributes

You can define attributes in a tag. For example, <person id = "123"> <person>

 

4. Special characters

Some special characters cannot appear in the label body. When encountering these characters, we need to use entity characters.

For example, for greater than and less than signs, xml will regard them as tags during parsing, and then the parsing may fail. Therefore, we should use entity characters to represent these characters.

 

5. Character Area

If we need to use a large number of special characters in a text, it is too much trouble to use entity characters to represent these special characters and it is not easy to read. In this case, we can use the character area, the text in the character area will be considered as common text by the parser and will not parse them. Usage:

<! [CDATA [character area content]>

 

6. processing commands

The Processing Command is to notify the xml interpreter how to process the xml file.

The following is an example of parsing xml files using CSS styles:

Processing Instruction format:
<? Xml-stylesheet type = "text/css" href = "a.css"?>

 

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.