XML Easy Learning Handbook (1) XML QuickStart _xml/rss

Source: Internet
Author: User
Tags closing tag html tags first row xml example

Objective

XML is becoming more and more hot, and the basic tutorials on XML are also ubiquitous on the web. But a lot of concepts and terminology are often daunting, and many friends ask me: What is the use of XML, we need to learn it? I would like to write a more comprehensive introduction to my personal experiences and experience in the learning process. First, there are two points to be sure:

First: XML is certainly the future trend of development, whether it is a web designer or Web programmer, should learn and understand in time, waiting will only let you lose the opportunity;

Second: New knowledge will certainly have many new concepts, try to understand and accept, you can improve. Do not be afraid and escape, after all, we are young.

Outline

This paper is divided into five parts. These are XML QuickStart, XML concepts, XML terminology, XML implementation, and XML example analysis. The last appendix describes the resources associated with XML. The author stands in the ordinary web designer's angle, in the plain vivid language, tells you all aspects of the XML, helps you to push through the mysterious veil of XML, quickly enters the new domain of XML.

Chapter One: A quick introduction to XML

A. What is XML?

Two. is XML a new concept?

Three. What are the benefits of using XML?

Four. is XML difficult to learn?

Five. The difference between XML and HTML

Six. Strict format of XML

Seven. More about XML

A. What is XML?

This is often the first question, and often on the first question you will not understand, because most of the textbooks answer:

XML is a shorthand for extensible Markup language, an extensible identity language. This is the definition of the standard. So what is the symbol language, and why is it called extensibility? has been a bit confusing. I think it would be better for us to understand this way:

You are already very familiar with HTML, it is a markup language, remember its full name: "Hypertext Markup Language" Hypertext Markup Language. I see? At the same time, there are many tags in html, similar, etc, are all in HTML
4.0 of the specifications and definitions, and XML allows you to create such a label, so called Extensibility.

Here are a few confusing concepts to remind you:

1.XML is not a markup language. It is just a meta language used to create markup languages (such as HTML). God, it's confusing again! It doesn't matter, you just have to know this: XML and HTML are different, and it's much more useful than HTML, and we'll look at that later.

2.XML is not an alternative to HTML. XML is not an upgrade of HTML, it is just a supplement to HTML, which extends more functionality for HTML. We will continue to use HTML for a long time. (But it's worth noting that the upgraded version of HTML is actually moving toward adapting XML.) )

3. You cannot use XML to write pages directly. Even if you include XML data, you can still convert it to HTML format to be displayed on the browser.

The following is an XML sample document (example 1) that represents the information for this article:

<myfile><br><br>

<title>xml Quick start</title><br><br>

<author>ajie</author><br><br>

<email>ajie@aolhoo.com</email><br><br>

<date>20010115</date><br><br>

</myfile>

Attention:

1. This code is just code, let you preliminary perceptual knowledge of XML, and can not achieve what specific applications;

2. A similar < title>,< author> statement is the markup (tags) that you create, and they are not the same as HTML tags, for example, where the < title> is the title of the article, and the < title in HTML > is the title of the page.

Two. is XML a new concept?

No. XML comes from SGML, an earlier markup language standard than HTML.

About SGML, let's take a quick look, you just need to have a rough idea.

The SGML full name is "Standard Generalized Markup Language" (Universal Identity language standard). See the name to know: it is a symbol of language standards, that is, all the logo language is based on SGML, of course, including HTML. SGML has a wide coverage, and all files in a certain format are SGML, such as reports, music scores, and so on, and HTML is the most common file format for SGML on the web. So, people jokingly called SGML the "Mom" of HTML.


XML is a simplified version of SGML, but omits the complex and infrequently used parts of it. (Oh, I get it!) Is the second "mother" of HTML, no wonder it is more powerful than HTML. Like SGML, XML can also be used in areas such as finance, research, and so on, and what we're talking about here is the use of XML in the Web.


Here, you should have a bit of a sense: XML is used to create markup languages that define HTML-like, and then use this markup language to display information. Three. What are the benefits of using XML?

Why do I need XML when I have HTML?

Because now the network application is more and more extensive, just rely on HTML single file type to deal with the ever-changing documents and data has not cluster heart, and HTML itself syntax is very not strict, seriously affect the network information transmission and sharing. (Think about how many designer brain cells are broken by browser-compatible questions.) People have already started to explore ways to meet the needs of various applications on the Web. SGML was possible, but SGML was too large and complex to program, and finally opted for "slimming" SGML---XML as a tool for data transfer and interaction in the next generation of Web applications.


What are the benefits of using XML? See the description of the Organization for International organizations (XML standard makers):

XML makes it more "simple and straightforward" to use SGML language on the Web: simplifying the process of defining file types, simplifying the process of programming and processing SGML files, and simplifying transfer and sharing on the web.


1.XML can be widely used anywhere on the web;

2.XML can meet the needs of network applications;

3. Using XML will make programming simpler;

4.XML easy to learn and create;

5.XML code will be clear and easy to read and understand;

It's still a little more abstract. Let's be slow in the example tutorials that follow to understand the powerful advantages of XML!

Four. is XML difficult to learn?

If you are interested in learning XML, you can't help asking: is XML difficult? What are the basics of learning XML?

XML is very simple and easy to learn. If you are familiar with HTML, you will find that the document is very similar to HTML, looking at the same sample document (Example 1):

? xml version= "1.0"?><br><br>

<myfile><br><br>

<title>xml Quick start</title><br><br>

<author>ajie</author><br><br>

<email>ajie@aolhoo.com</email><br><br>

<date>20010115</date><br><br>

</myfile>

The first line is an XML declaration that indicates that the document follows the specification of XML version 1.0.

The second line defines the first element in the document (element), also known as the root element: < myfile>. This is similar to the < html> opening tag in HTML. Note that this name is freely defined by yourself.

The following four child elements are defined: Title,author,email, and date. Explain the title, author, mailbox and date of the article respectively. Of course, you can use Chinese to define these tags, and it looks more easy to understand:
<?xml version= "1.0" encoding= "GB2312"?>

< articles >

< title >xml Easy Learning Manual </title >

< author >ajie</>

< mail box >ajie@aolhoo.com</>

< date >20010115</date >

</articles >

This is the XML document, any HTML-mastering user can write such a simple XML document directly.

In addition, learning XML must also master a scripting language, often JavaScript and VB script. Because XML data is invoked and interacted with script implementation HTML. Let's look at one of the simplest examples (example 2):

1. Save the following code as MyFile.htm


<script language= "JavaScript" for= "window" event= "onload" >

var xmldoc = new ActiveXObject ("Microsoft.XMLDOM");

Xmldoc.async= "false";

Xmldoc.load ("Myfile.xml");

nodes = XmlDoc.documentElement.childNodes;

Title.innertext = Nodesitem (0). text;

Author.innertext = Nodes.item (1). text;

Email.innertext = Nodes.item (2). text;

Date.innertext = Nodes.item (3). text;

</script>

<title> call XML data in HTML </title>

<body bgcolor= "#FFFFFF" >

<b> Title: </b>

<span id= "title" > </span>

<b> Author: </b>>

<span id= "Author" ></span>

<b> Mail: </b>

<span id= "Email" ></span>

<b> Date:</b>

<span id= "Date" ></span>

</body><br><br>

2. Save the following code as Myfile.xml


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

<myfile>

<title>xml Easy Learning Handbook </title>

<author>ajie</author>

<email>ajie@aolhoo.com</email>

<date>20010115</date>

</myfile>


3. Put them in the same directory, with IE5 above version of the browser open, you can see the effect. Learning and mastering a script, you will really understand the powerful features of XML.

Five. The difference between XML and HTML

Both XML and HTML come from SGML, they all contain tags, have similar syntax, and the biggest difference between HTML and XML is that HTML is a stereotyped markup language that is described with intrinsic markup to display Web page content. For example < h1> represents the first row of headings, with a fixed size. In contrast, XML does not have a fixed tag, XML can not describe the specific appearance of the Web page, content, it is just describing the content of the data form and structure.


This is a qualitative distinction: the Web page mixes the data with the display, while XML separates the data from the display.

We look at the example above, in myfile.htm, we only care about the way the page is displayed, we can design different interfaces, layout the page in different ways, but the data is stored in the Myfile.xml without any change.


(If you're a programmer, you'll be surprised to find that this is very similar to the idea of modular object-oriented programming!) In fact, the Web page is not a procedure? )

It is this distinction that makes XML easy, efficient and scalable in network applications and information sharing. Therefore, we believe that XML as an advanced data processing method, will make the network across to a new realm.

Six. Strict format of XML

Drawing on the lessons of the loose HTML format, XML insists on a "good format" from the start.

Let's look at some of the HTML statements that are visible in HTML:

1.

Sample


2.< b>< i>sample</b></i>


3.< td>sample</td>


4.< Font color=red>samplar</font>


In an XML document, the syntax of several of these statements is incorrect. Because:

1. All markings must have a corresponding closing tag;

2. All XML tags must be properly nested;

3. All XML tags are case-sensitive;

4. All marked attributes must be enclosed in "";

So the above statement is correctly written in XML

1.

Sample


2.< b>< i>sample</i></b>


3.< td>sample</td>


4.< font color= "Red" >samplar</font>


In addition, XML tags must follow the following naming conventions:

1. The name may contain letters, numbers and other letters;

2. Name cannot begin with number or "_" (underline);

3. Names cannot begin with the letter XML (or XML or XML ...);

4. The name cannot contain spaces.

Any error in the XML document results in the same result: The Web page cannot be displayed. Browser developers have reached an agreement to implement rigorous and critical parsing of XML, and any minor errors will be reported. You can change the above myfile.xml, for example, change the < email> to < Email>, and then open myfile.xml directly with IE5, and get an error message page:


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

<myfile>

<title>xml Easy Learning Handbook </title>

<author>ajie</author>

<Email>ajie@aolhoo.com</email>

<date>20010115</date>

</myfile>

Seven. More about XML

Well, by now you already know:

1. what is XML;

The relationship and distinction between 2.XML,HTML,SGML;

3.XML of simple application.

Congratulations to you! You are no longer ignorant of XML and are at the forefront of web technology. The whole learning process seems not very difficult oh:

If you have more interest in XML and want to learn more about XML details and other practical techniques, welcome to the next chapter: the concept of XML.

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.