SoFunction
Updated on 2025-04-07

XML Easy Learning Manual (Good) Page 1/3

I would like to write a relatively comprehensive introduction article based on my personal experience and experience in the learning process.
First of all, there are two points that need 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 in time. Waiting will only make you lose opportunities;
Second: There will definitely be many new concepts in new knowledge. Only by trying to understand and accept it can you improve. Don't be afraid or escape, after all, we are still young.
outline
This article is divided into five parts. These are the quick start of XML, the concept of XML, the terminology of XML, the implementation of XML, and the instance analysis of XML. The last appendix introduces the resources related to XML. The author stands from the perspective of ordinary web designers and uses plain and vivid language to tell you all aspects of XML, helping you to clear the mystery of XML and quickly enter the new field of XML.


Common problems for beginners in XML
1. What is XML? (Don't say it's an extensible markup language or something)
2. What can XML do? How to do it? (No answer is required, just list a simple example)

1: XML is used to describe data.
2: Give an example: There is database A and database B. The standards between them are different and cannot be passed on to each other. Then you can put the data in XML, and then A and B can transmit data together.
Replenish:
First of all, you need to have a concept. You'd better not use XML to design web pages. It's not that it's not possible, but that it's just that XML is not a substitute for HTML.
With this concept, there will not be many tutorials after reading one by one, and I still don’t know what XML does. It’s very clear
XML is for describing data
Start learning XML:
1. Tools: XMLSPY2005,
2. Where does learning XML start?
That is, what I want to explain is: write XML first or write DTD or XML Schemas first.
Most of the tutorials start with XML, let’s talk about DTD... Let’s talk about XML Schemas...
But I personally think that I first understand the basic syntax of XML, and then skip DTD and start with Schemas.
This will not make DTD uninterested...and then you will have a certain understanding of DTD. Here I want to explain, I think I will write it first
It is better to write XML for a Schemas. That is, build a model first and then fill in the data.


Chapter 1: Quick Start of XML
1. What is XML?
2. Is XML a new concept?
3. What are the benefits of using XML?
4. Is XML difficult to learn?
5. The difference between XML and HTML
6. Strict formatting of XML
7. More about XML
1. What is XML?

This is often the first question, and you often don’t understand the first question, because most textbooks answer this:
XML is the abbreviation of Extensible Markup Language, an extensible markup language. This is the definition of the standard. So what is a logo language and why is it called extension? It's already a little confused. I think it would be better for us to understand this way:
You are already very familiar with HTML. It is a markup language. Do you remember its full name: "Hypertext Markup Language" Hypertext markup language. Understood? At the same time, there are many tags in HTML, similar, etc., all in HTML
Specifications and definitions in 4.0, while XML allows you to create such tags yourself, so it is called extensibility.
Here are a few confusing concepts to remind you:
Not markup language. It is just a meta-language used to create markup languages ​​(such as HTML). God, I'm confused again! It doesn't matter, you just need to know this: XML and HTML are different, and their uses are much more extensive than HTML, which we will introduce in detail later.
Not an alternative to HTML. XML is not an upgrade to HTML, it is just a supplement to HTML, extending more features to HTML. We will continue to use HTML for a longer period of time. (But it is worth noting that the upgraded version of HTML, XHTML, is indeed moving closer to adapting to XML.)
3. You cannot use XML to write web pages directly. Even if XML data is included, it still needs to be converted into HTML format before it can be displayed on the browser.
The following is an XML sample document (Example 1) used to represent the information in this article:
<myfile>

<title>XML Quick Start</title>

<author>ajie</author>

<email>ajie@</email>

<date>20010115</date>

</myfile>

Notice:

1. This code is just code, which allows you to have a preliminary understanding of XML and cannot implement any specific applications;
2. Statements like < title> and < author> are tags created by themselves. They are different from HTML tags. For example, the < title> here means the article title, and the < title> in HTML is the page title.
2. Is XML a new concept?
no. XML originates from SGML, a logo language standard earlier than HTML.
Regarding SGML, let’s take a brief look, you only need to have a general concept.
The full name of SGML is "Standard Generalized Markup Language". You can tell by looking at the name: it is the standard of logo language, that is, all logo languages ​​are formulated in accordance with SGML, including HTML of course. SGML has a wide coverage. All files with certain formats belong to SGML, such as reports, music scores, etc. HTML is the most common file format for SGML on the Internet. Therefore, people jokingly call SGML the "mother" of HTML.

XML is a simplified version of SGML, but the complex and infrequently used parts are omitted. (Oh, I understand! It is the second "mother" of HTML, no wonder it is more powerful than HTML.) Like SGML, XML can also be used in various fields such as finance and scientific research. What we are talking about here is just the application of XML in the web.

At this point, you should understand a little: XML is used to create a markup language that defines HTML-like, and then use this markup language to display information. 3. What are the benefits of using XML?
With HTML, why do you still need to use XML?
Because the Internet is becoming more and more widely used, relying solely on a single HTML file type to process ever-changing documents and data, and the HTML itself is not strict, which seriously affects the transmission and sharing of network information. (Think about the problem of browser compatibility, how many designers' brain cells are damaged?) People have long begun to discuss how to use methods to meet the needs of various applications on the Internet. It is OK to use SGML, but SGML is too large and programming is complicated, so I finally chose "weight loss" SGML--XML as a tool for data transmission and interaction for the next generation of web applications.

What are the benefits of using XML? Let’s take a look at the explanation of the w3c organization (XML standard maker):
XML makes using SGML language more "simple and direct" on the network: simplifies the process of defining file types, simplifies the process of programming and processing SGML files, and simplifies the delivery and sharing on the web.

It can be widely used anywhere on the web;
Can meet the needs of network applications;
3. Using XML will make programming easier;
Easy to learn and create;
The code will be clear and easy to read comprehension;
Still a little abstract. Let’s slowly appreciate the powerful advantages of XML in the example tutorial below!
4. Is XML difficult to learn?
If you are interested in learning XML, you can’t help but ask: Is XML difficult? What kind of foundation does it take to learn 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. Look at the same example document (Example 1):
?xml version="1.0"?>

<myfile>

<title>XML Quick Start</title>

<author>ajie</author>

<email>ajie@</email>

<date>20010115</date>

</myfile>
The first line is an XML declaration that indicates that the document follows the specification of version 1.0 of XML.
The second line defines the first element in the document, also known as the root element: <myfile>. This is similar to the <HTML> tag in HTML. Note that this name is defined by yourself.
The following are four child elements: title, author, email, and date. Describe the title, author, email and date of the article respectively. Of course, you can define these tags in Chinese, which looks easier to understand:
<?xml version="1.0" encoding="GB2312"?>
<Article>
<Title>XML Easy Learning Manual</Title>
<Author>ajie</Author>
<Mailbox>ajie@</Mailbox>
<Date>20010115</Date>
</Article>

This is the XML document. Any netizens who master HTML can write such a simple XML document directly.
In addition, learning XML must also master a page scripting language, common are javascript and VB script. Because XML data is used to implement calls and interactions in HTML using script. Let's look at the simplest example (Example 2):
1. Save the following code as

<html>
<head>
<script language="JavaScript" for="window" event="onload">
var xmlDoc = new ActiveXObject("");
="false";
("");
nodes = ;
= nodesitem(0).text;
= (1).text;
= (2).text;
= (3).text;
</script>
<title>Calling XML data in HTML</title>
</head>
<body bgcolor="#FFFFFF">
<b>Title: </b>
<span > </span>
<b>Author: </b>>
<span ></span>
<b>Mailbox: </b>
<span ></span>
<b>Date:</b>
<span ></span>
</body>

</html>

2. Save the following code as

<?xml version="1.0" encoding="GB2312"?>
<myfile>
<title>XML Easy Learning Manual</title>
<author>ajie</author>
<email>ajie@</email>
<date>20010115</date>
</myfile>

3. Put them in the same directory and open them in IE5 or above browsers to see the effects. Learn and master a script and you will truly understand the incomparable power of XML.
5. The difference between XML and HTML

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

This is a qualitative difference: web pages mix data and displays, while XML separates data and displays.

Let’s look at the example above. In this case, we only care about the display of the page. We can design different interfaces and type the page in different ways, but the data is stored and does not require any changes.

(If you are a programmer, you will be surprised to find that this is extremely similar to the idea of ​​modular object-oriented programming! In fact, isn’t a web page a kind of program?)

It is this difference that makes XML convenient, efficient and scalable in network applications and information sharing. Therefore, we believe that XML, as an advanced data processing method, will lead the network to a new level.
123Next pageRead the full text