XML easy learning Manual (relatively good) page 1/3

Source: Internet
Author: User
Tags xml example

I want to write a comprehensive introduction to my personal learning experience and experience.
First, there are two points to be affirmed:
First, XML is definitely the future development trend. Whether it is a web designer or a Web programmer, you should learn and understand it in time. Waiting will only lead you to lose the opportunity;
Second, new knowledge will certainly have many new concepts. You can only improve your understanding and acceptance. Don't be afraid and escape. After all, we are still young.
Outline
This article is divided into five parts. They are respectively XML Quick Start, XML concept, XML terminology, XML implementation, and XML instance analysis. At last, the appendix introduces the relevant XML resources. From the perspective of common web designers, the author tells you about all aspects of XML in plain and vivid language, helping you open the secrets of XML and quickly step into the new field of XML.

Common problems for beginners of XML
1. What is XML? (Not a scalable markup language)
2. What can XML do? How? (You don't need to answer the question. You just need to give a simple example)

1: XML is used to describe data.
2: for example, database A and database B have different standards and cannot communicate with each other. then you can put the data in XML, and then you can transfer data between A and B.
Supplement:
First, you need to have a concept. You 'd better not design webpages using XML. It doesn't mean no, it just needs to be explained that XML is not an alternative to HTML.
With this concept, we won't be able to read a lot of tutorials one by one. We still don't know what to do with XML.
XML is used to describe data.
Start learning XML:
1. Tool: XMLSPY2005,
2. Where can I start learning XML?
That is, whether to write XML or DTD or XML Schemas first.
Most of the tutorials start with XML, and DTD... and XML Schemas...
But I personally think, first understand the basic syntax of XML, and then skip DTD, starting with Schemas.
In this way, you will not be interested in the DTD. Then, you will be able to understand the DTD. Here we will explain how to write it first.
It is better to write XML after a Schemas job. That is, first create a model and then fill in the data.

Chapter 1: XML Quick Start
1. What is XML?
2. Is XML a new concept?
3. What are the advantages of using XML?
4. Is XML hard to learn?
V. Differences between XML and HTML
Vi. Strict XML format
7. More information about XML
1. What is XML?

This is often the first question, and you may not understand the first question, because most of the textbooks answer this question:
XML is short for Extensible Markup Language. This is a standard definition. So what is a markup language and why is it extensibility? It is a bit confusing. I think it will be better to understand this:
You are very familiar with HTML. It is a Markup Language. Remember its full name: "Hypertext Markup Language" Hypertext Markup Language. Understand? At the same time, there are many tags in HTML, such:
4.0 standards and definitions, while XML allows you to create such labels, so it is called scalability.
Here are several confusing concepts to remind everyone:
1. XML is not a markup language. It is only used to create a markup language (such as HTML. Day, confused again! It doesn't matter. You only need to know this: XML and HTML are different. It is more useful than HTML. We will introduce it in detail later.
2. XML is not an alternative to HTML. XML is not an HTML upgrade. It is just a supplement to HTML and provides more functions for HTML extension. We will continue using HTML for a long period of time. (However, it is worth noting that the upgraded HTML version of XHTML is indeed moving closer to adapt to XML .)
3. You cannot use XML to directly write web pages. Even if XML data is contained, it must be converted to HTML format for display on the browser.
The following is an XML example document (Example 1) used to indicate the information in this document:
<Myfile>

<Title> XML Quick Start </title>

<Author> ajie </author>

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

<Date> 20010115 </date>

</Myfile>

Note:

1. This piece of code is just code. It gives you a preliminary understanding of XML and cannot implement specific applications;
2. the <title> and <author> statements are self-created tags. They are different from HTML tags. For example, <title> indicates the title of an article, <title> in HTML is the page title.
2. Is XML a new concept?
No. XML is derived from SGML, a markup language standard that is earlier than HTML.
For more information about SGML, you only need to have a general concept.
SGML stands for "Standard Generalized Markup Language ). Look at the name to know: it is the standard of the markup language, that is to say, all the Markup languages are developed according to SGML, of course, including HTML. SGML has a wide coverage. All files in a certain format belong to SGML, such as reports and music scores. HTML is the most common file format on the SGML network. Therefore, SGML is the "mother" of HTML ".

XML is a simplified version of SGML, but it only skips the complicated and uncommon parts. (Oh, see! Is the second "mother" in HTML. No wonder it is more powerful than HTML .), Like SGML, XML can also be applied in various fields such as finance and scientific research. Here we will talk about the use of XML in web.

Here, you should understand that XML is used to create a markup language similar to HTML, and then use this markup language to display information. 3. What are the advantages of using XML?
With HTML, why do we still need XML?
Because the network is more and more widely used, it is no longer necessary to handle ever-changing documents and data by simply using a single HTML file type, and the syntax of HTML itself is not strict, seriously affects network information transmission and sharing. (Think about how many designer brain cells are broken by browser compatibility issues .) People have already begun to explore how to meet the needs of various applications on the network. SGML can be used, but SGML is too large, complex programming, so the final choice of "Weight Loss" SGML---XML as the next generation of web application of data transmission and interaction tools.

What are the advantages of using XML? Let's take a look at the w3c organization (XML standard setter) Description:
XML makes it easier to use the SGML language on the network "simple and direct": it simplifies the process of defining file types and simplifies the process of programming and processing SGML files, it simplifies 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 makes programming easier;
4. XML is easy to learn and create;
5. the XML code is clear and easy to read and understand;
Or abstract. Let's take a look at the powerful advantages of XML in subsequent instance tutorials!
4. Is XML hard to learn?
If you are interested in learning XML, you may ask: is XML difficult? What is the basis for learning XML?
XML is very simple and easy to learn. If you are familiar with HTML, you will find that its documentation is very similar to HTML. See the same example document (Example 1 ):
? Xml version = "1.0"?>

<Myfile>

<Title> XML Quick Start </title>

<Author> ajie </author>

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

<Date> 20010115 </date>

</Myfile>
The first line is an XML declaration, indicating that the document complies with the XML 1.0 specification.
The second line defines the first element in the document, also known as the root element: <myfile>. This is similar to the <HTML> Start mark in HTML. Note that this name is customized by yourself.
The following four sub-elements are defined: title, author, email, and date. The title, author, email address, and date of the article are described respectively. Of course, you can define these labels in Chinese to make it easier to understand:
<? Xml version = "1.0" encoding = "GB2312"?>
<Article>
<Title> XML easy learning manual </title>
<Author> ajie </author>
<Email> ajie@aolhoo.com </Email>
<Date> 20010115 </date>
</Article>

This is the XML document. Anyone familiar with HTML can directly write such a simple XML document.
In addition, to learn XML, you must master a Page scripting language, commonly known as javascript and VB script. Because XML data uses scripts to implement calls and interactions in HTML. Let's look at a simple example (Example 2 ):
1. Save the following code as myfile.htm

<Html>
<Head>
<Script language = "JavaScript" for = "window" event = "onload">
Var xmlDoc = new ActiveXObject ("Microsoft. XMLDOM ");
XmlDoc. async = "false ";
XmlDoc. load ("myfile. xml ");
Nodes = xmlDoc.doc umentElement. 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>
</Head>
<Body bgcolor = "# FFFFFF">
<B> title: </B>
<Span id = "title"> </span>
<B> author: </B>
<Span id = "author"> </span>
<B> mailbox: </B>
<Span id = "email"> </span>
<B> date: </B>
<Span id = "date"> </span>
</Body>

</Html>

2. Save the following code as myfile. xml

<? Xml version = "1.0" encoding = "GB2312"?>
<Myfile>
<Title> XML easy learning manual </title>
<Author> ajie </author>
<Email> ajie@aolhoo.com </email>
<Date> 20010115 </date>
</Myfile>

3. Put them in the same directory and open them in IE5 or a later browser to see the effect. Learn and master a script, and you will truly understand the powerful functions of XML.
V. Differences between XML and HTML

Both XML and HTML come from SGML. They both contain tags and have similar syntaxes. The biggest difference between HTML and XML is that HTML is a fixed markup language, it uses inherent tags to describe and display webpage content. For example, <H1> indicates the title of the first line, which has a fixed size. In contrast, XML does not have a fixed mark. XML cannot describe the specific appearance and content of a webpage. It only describes the data format and structure of the content.

This is a qualitative difference: Web pages mix data and display, while XML separates data and display.

For example, in myfile.htm, We only care about the page display mode. We can design different interfaces and typeset pages in different ways, but the data is stored in myfile. xml.

(If you are a programmer, you will be surprised to find that this is very similar to the idea of Modular object-oriented programming! In fact, why is a Web page not a program ?)

The difference makes XML easy, efficient, and scalable in terms of network applications and information sharing. Therefore, we believe that XML, as an advanced data processing method, will bring the network to a new realm.

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.