Xml learning notes, mass route learning notes

Source: Internet
Author: User
Tags xml attribute

Xml learning notes, mass route learning notes
1. xml Introduction 1.1. What is xml?

XML refers to the EXtensible Markup Language)

XML is a markup language, similar to HTML

The purpose of XML is to transmit data rather than display data.

The XML tag is not predefined. You need to customize the tag.

XML is designed to be self-descriptive.

XML is W3C recommendation Standard

1.2. Comparison between xml and html

XML is not an alternative to HTML.

XML and HTML are designed for different purposes:

XML is designed to transmit and store data, with the focus on data content.

HTML is designed to display data. Its focus is on the appearance of the data.

HTML is designed to display information, while XML is designed to transmit information.

XML is a supplement to HTML.

XML is not an alternative to HTML. It is important to understand this. In most web applications, XML is used to transmit data, while HTML is used to format and display data.

The best description of XML is that XML is an information transmission tool independent of software and hardware.

1.3. Use of xml

1) XML separates data from HTML

2) Simplified XML data sharing

3) Simplified XML Data Transmission

4) xml can be used as a configuration file

5) xml can act as a small database

2. xml syntax 2.1. xml Tree Structure

XML documents form a tree structure that begins with "root" and expands to "branches ".

<? Xml version = "1.0" encoding = "UTF-8"?>

<Bookstore>

<Book category = "COOKING">

<Title lang = "en"> Everyday Italian </title>

<Author> Giada De Laurentiis </author>

<Year> 2005 </year>

<Price> 30.00 </price>

</Book>

<Book category = "CHILDREN">

<Title lang = "en"> Harry Potter </title>

<Author> j k. Rowling </author>

<Year> 2005 </year>

<Price> 29.99 </price>

</Book>

<Book category = "WEB">

<Title lang = "en"> Learning XML </title>

<Author> Erik T. Ray </author>

<Year> 2003 </year>

<Price> 39.95 </price>

</Book>

</Bookstore>

2.2. Syntax Rules

All XML elements must have close labels

XML tags are case sensitive.

Ø XML must be correctly nested

XML documents must have only one root element.

XML Attribute values must be enclosed in quotation marks

Annotation in XML: <! -Comment content -->

Ø in XML, spaces are retained

Ø line feed with LF storage in XML

2.2.1 entity reference in. xml

In XML, some characters have special meanings.

If you put the character "<" in an XML element, an error occurs because the parser starts to treat it as a new element.

XML errors will occur:

<Message> if salary <1000 then </message> to avoid this error, replace "<" with an entity reference:

<Message> if salary <1000 then </message> in XML, there are five predefined entity references:

Ø & lt; <less

Ø & gt;> greater

Ø & amp; & and number

Ø & apos; 'single quotation marks

& Quot; "quotation marks

Note: In XML, only the characters "<" and "&" are indeed invalid. It is a good habit to replace it with Entity references.

2.3. Document declaration

<? Xml version = "1.0" encoding = "UTF-8" standalone = "yes"?>

The xml Document declaration is placed in the first line of the XML document.

The XML document Declaration consists of the following parts:

Ø version--The document complies with XML1.0 specifications

Ø encoding--document character encoding, such as "gb2312"

Define whether standalone is used independently.

Standalone = "yes" the dtd file is in this file

Standalone = "no" by default. The dtd file is not in this file.

2.4. Element 2.4.1. What is an xml element?

An XML element refers to the portion of the tag that starts from (and includes) and ends until (and includes. An element can contain other elements, text, or a mixture of the two. The element can also have attributes.

An XML element is a tag that appears in an XML file. A tag can be divided into a start tag and an end tag. A tag can be written in the following forms:

TAG body: <a> www.sohu.cn </a>

Without tags: <a> </a>, abbreviated as: <a/>

Several sub-tags can also be nested in a tag. However, all labels must be reasonably nested and cross-Nesting is absolutely not allowed. For example, <a> welcome to <B> www.sohu.org </a> </B>

2.4.2. xml Element naming rules

The name can contain letters, numbers, and other characters.

The name cannot start with a number or punctuation.

The name cannot start with the character "xml" (or XML or Xml ).

The name cannot contain spaces.

The name cannot contain: No.

Name case sensitive

2.5. Attributes

<Student ID = "100">

<Name> TOM </Name>

</Student>

Ø the attribute values are separated by double quotation marks (") or single quotation marks ('). (If the attribute values contain', separate them with '. If yes, separate them)

A single element can have multiple attributes. Its basic format is: <element name attribute name = "attribute value">

The specified attribute name can only appear once in the same element tag.

Ø attribute values cannot include <,> ,&

2.6. CDATA

Some content may not be parsed and executed by the parsing engine, but is processed as the original content, which is used to interpret the entire text segment as pure character data rather than markup. Contains a large number of <,>, &, or "characters. All characters in the CDATA section are treated as constants of the element character data, rather than XML tags.

Syntax:

<! [CDATA [

........

]>

Enter any character (except]>)

Ø Nesting is not allowed

2.7. processing commands

Processing Command (PI ). The processing command is used to direct the parsing engine to parse the XML document content.

For example, you can use the XML-stylesheet command in the xml document to notify the XML parsing engine and apply the css file to display the content of the xml document. <? Xml-stylesheettype = "text/css" href?“my.css "?>

The processing command must start with "<?" Starting with "?>" As the end, XML declaration statements are the most common processing commands.


How to Learn XML?

In fact, xml is not difficult at all ~~ In addition, if you learn xml directly, you also learn a lot of dynamic things ......
Therefore, we recommend that you take a look at xml-related materials and then write an xml page to display a webpage! (Any xml instance)
This is done. xml in android is just a piece of cake !!

XML learning: How to Use the XML language

XML can be used to separate data from HTML. XML allows you to store data outside HTML files. When XML is not used, HTML is used to display data, and the data must be stored in the HTML file. When XML is used, the data can be stored in the separated XML document. This method allows you to focus on displaying and layout data using HTML, and ensure that HTML files do not need to be modified when data changes are made. This facilitates page maintenance. XML data can also be stored in HTML pages in the form of "data island. You can still focus on using HTML to format and display data. XML is used to exchange data. Through XML, we can exchange data between incompatible systems. In real life, computer systems and database systems store N ^ N forms of data. For developers, the most time-consuming is to exchange data between systems distributed across networks. Converting data to XML format for storage can greatly reduce the complexity of data exchange and make the data readable by different programs. XML and B2B use XML to exchange financial information on the network. In the near future, we hope To see a lot of XMl and B2B (Business To Business) applications. XML is becoming the main language used to exchange financial information between commercial systems across networks. Many B2B-related XML-based applications are under development. XML can be used to share data. XML can be used to share data in plain text files. Since XML data is stored in plain text format, XML provides a data sharing method unrelated to software and hardware. This makes it easy to create a data file that can be read by different applications. Similarly, it is much easier for us to upgrade the provincial operating system, servers, applications, and browsers. XML can be used to store data. XML can be used to store data in plain text files. A large amount of data can be stored in XML files or databases. Applications can read, write, and store data. General programs can display data. XML can make full use of data to use XML, so that your data can be used by more users. Since XML is irrelevant to software, hardware, and applications, it can make your data available to more users and devices, not just HTML-based browsers. Other clients and applications can process your XML documents as data sources. Just as they treat databases, your data can be processed by various "readers, it is convenient for some people, such as the blind or the disabled. XML can be used to create new languages. XML is the mother of WAP and WML languages. The Wireless Markup Language (WML) identifies an Internet program running on a handheld device (such as a mobile phone. Looking forward to the future, if developers have enough foresight, future applications should use XML to store data. In the future, our word processors, spreadsheet software, and databases should be able to read data from each other in plain text format without the need for format conversion. We can only look forward to the approval of Microsoft and other software developers.

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.