Full version of the XML note (i)

Source: Internet
Author: User
Tags cdata processing instruction xml parser

full version of the XML note (i)

Good memory is not as bad as writing, while learning to forget that I have to admit that notes are so important. Recently learning XML requires a note to be taken for later viewing. The content of XML is not much, but it has never been studied before, so it is daunting. So recently the system learned a bit, do a summary.

The XML content is roughly the following aspects

1.XML and its syntax.

2.XML constrained schema of the DTD XML constraint (two constraints).

3.XML Programming (CRUD---Create Read Update Delete).

4. Three kinds of XML parser Dom sax dom4j.

To be narrated in turn, according to the number of four records explained.

1. What is XML?

XML refers to Extensible Markup Language (extensible Markup Language), which is a markup language, similar to HTML.

The purpose is to represent data, not to display it.

XML tags require users to define their own labels.

XML technology is published by the World Wide Web Consortium WWW Consortium, and is now followed by the XML1.0 specification published by the organization in 2000.

The data in the XML file needs to be read out by the program, which is the 4th three parsers that are presented in the fourth article.

The XML language is a common format for data interchange.

2.XML Common Applications

as a configuration file for data, such as Java development, the traditional configuration file is the *.properties property file.

Used as a configuration file for software to describe the relationships between program modules, such as STRUTS2, Spring, and hibernate.

Used as an interface layout file in Android

3. Syntax

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

Elements:

A label is divided into start and end tags (cannot be omitted).

A label has the following forms of writing: Contains the label body: <mytag>some content</mytag> does not contain a label body:<mytag/> a tag can nest several sub-labels, but all labels must be properly nested,       Cross nesting is not allowed. An XML document must have only one root tag, and the other tag is a child tag or a grandchild tag for that root tag.

Naming conventions:

An XML element can contain letters, numbers, and other visible characters, but must adhere to some of the following specifications:

Case sensitivity, such as,<p> and <p>, are two different tokens.

You cannot start with a number or a "_" (underscore). You cannot start with XML (or XML, or XML, and so on).

Cannot contain spaces.

The middle of the name cannot contain a colon (:) (for special purposes).

Property

A label can have multiple properties, each with its own name and value, for example: <mytag name= "Value"/> Property value must be enclosed in double quotation marks (") or single quotation marks (')

The definition attribute must follow the same naming convention as the label in XML technology, the information represented by the tag attribute, if there is no tag body, can be changed to describe it in the form of a child element, for example:

<MyTag> 
<name>
<FirstName>
</Firstnamename>
<Secondname>
</Secondname>
</name>
</MyTag>

Comments

<!--large segment notes ...-and annotations cannot be nested

CDATA Zone

CDATA is the abbreviation of character data: the label as plain text content; Syntax: <! [cdata[content]]> such as: <! [Cdata[<mytag>mytag</mytag>]]>

Special characters

Special character processing instruction (processing instruction) (PI)

Processing instructions, referred to as pi (processing instruction). Role: Used to direct how the software parses an XML document. Syntax: Must be "<?" As the beginning, with "?>" as the end.

Common processing Directives: XML declaration: <?xml version= "1.0" encoding= "GB2312"?> xml-stylesheet directive: function: Indicates the CSS style XSL used by the XML document.

<?xml-stylesheet type= "Text/css" href= "some.css"?> Note: Label elements that are named in Chinese do not work.

The first part ends, there is not much code, it is easy to see.

    

    

Full version of the XML note (i)

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.