Foreword
XML is getting hotter and visible on the basic tutorial network of XML. However, a lot of concepts and terms often make people feel daunting, many friends ask me: What is the use of XML, do we need to learn it? I want to write a comprehensively introduction article on my personal learning process. First, there are two points to be affirmative:
First: XML is definitely a future development trend, whether it is web designer or a network programmer, you should learn and understand in time, waiting for you to lose the opportunity;
Second: New knowledge will definitely have many new concepts, try to understand and accept, you may increase. Don't be afraid and escape, after all, we are still young.
outline
This article is divided into five parts. They are XML quick start, XML concept, XML term, XML implementation, XML instance analysis. The last apartment introduces the resources of XML. The author stood in the perspective of ordinary web designers, tells you the side of XML in the way, helps you open XML's mystery, and quickly enter XML new fields.
Chapter 1: XML Quick Start
1. What is XML?
II. Is XML a new concept?
3. What is the benefit of using XML?
IV. Is XML difficult to learn?
V. XML and HTML
Sixth. XML strict format
7. More about XML
1. What is XML?
This is often the first question, and you will often don't understand on the first question, because most of the textbooks answer this:
XML is an extensible Markup Language, an extensibility identifier language. This is a standard definition. So what is a sign language, why is it scalable? It has been a bit confused. I think we will understand it like this:
You are very familiar with HTML, it is a tag language, remember its full name: "Hypertext Markup Language" hypertext tag language. understood? At the same time, there are many labels, similar, etc. in HTML, etc., are all in HTML 4.0, and the XML allows you to create such a label, so it is called scalability.
There are several easily confusing concepts to remind everyone:
1.xml is not a markup language. It is just a meta-language used to create tag language (such as HTML). God, it is confused! Don't matter, you just know this: XML and HTML are different, and it uses a wide range of HTML, we will be carefully introduced later.
2.xml is not an alternative product of HTML. XML is not an HTML upgrade, it is just HTML supplements, and extension more features for HTML. We will continue to use HTML in a longer period of time. (But it is worth noting that HTML upgrade version XHTML is indeed close to the adaptation XML.)
3. You cannot write a web page directly with XML. Even if the XML data is included, it is still necessary to convert to an HTML format to display on the browser.
Below is a XML sample document (Example 1), used to represent this article:
myfile>
note:
1. This code is just the code, so that you will preliminary feelings to know XML, do not implement any specific applications;
2. Among these statements like
II. Is XML a new concept?
Not. XML comes from SGML, a logo language standard than HTML.
About SGML, let's take a brief understanding, you only need to have a general concept.
SGML is full name is "Standard Generalized Markup Language". Look at the name: It is the standard of the logo language, that is, all the sign languages are set in accordance with SGML, of course, HTML. The coverage of SGML is very wide. Any file with a certain format belongs to SGML, such as report, music, etc., HTML is the most common file format on the network. Therefore, people joking SGML is HTML "Mom".
And XML is the simplified version of SGML, but it is not omitted in which complex and uncommon parts are omitted. (Oh, understand! It is html second "Mother", it is no wonder that it is powerful than HTML function. Application.
Here, you should have a bit clear: XML is used to create a tag language that defines a html, and then use this tag language to display information. 3. What is the benefit of using XML?
HTML, why still need to use XML?
Because the network is now more and more extensive, only the HTML single file type is handled by the HTML single file type, and the data has been made upless, and the HTML itself is not strict, and the network information is transmitted and shared. (Think about how many designers' brain cells are hurt in browser-compatible problems.) People have long been to explore what method is used to meet the needs of various applications on the network. Using SGML is ok, but SGML is too large, complicated programming, and finally selects "weight loss" SGML - XML as a data transfer and interaction of the next generation of Web.
What is the benefit of using XML? To see the description of the W3C organization (XML standard maker):
XML makes more "simple and direct" on the network: Simplify the process of defining file types, simplifying the process of programming and handling SGML files, simplifying the transfer and sharing on the Web.
1.xml can be widely used in the web from anywhere;
2.xml meets the needs of network applications;
3. Use XML will make the programming simpler;
4.XML facilitates learning and creation;
5.xml code will be clear and easy to read;
Still abstract. Let us take the powerful advantage of XML in the following instance tutorial!
IV. Is XML difficult to learn?
If you are interested in learning XML, can you ask: Is XML difficult? What is the foundation of learning XML?
XML is very simple, learning is easy. If you are familiar with HTML, you will find its documentation and HTML very similar, see the same example document (Example 1):
? Xml version = "1.0"?>
myfile>
The first line is an XML declaration that means that the document is followed by the 1.0 version of XML.
The second line defines the first element in the document, also known as the root element:
Then define four sub-elements below: Title, Author, Email, and Date. The title of the article, the author, email, and date will be explained separately. Of course, you can use Chinese to define these tags, it seems more convenient to understand: XML Version = "1.0" encoding = "GB2312">>
Article>
This is the XML document, any netizen who masters HTML can directly write this simple XML document.
In addition, learning XML must also master a page scripting language, common is JavaScript and VB Script. Because XML data is called and interacting in HTML using Script. Let's take a simplest example (Example 2):
1. Save the following code as MyFile.htm
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>
hEAD>
Title: b>
span>
Author: b >>
span>
Mailbox: b>
span>
Date: b>
span>
Body>
Html>
2. The following code is saved as myfile.xml
XML Version = "1.0" encoding = "GB2312"?>
myfile>
3. Place them in the same directory, open with IE5 or higher, and you can see the effect. Learn and master a Script, you will really understand the powerful power of XML.
V. XML and HTML
Both XML and HTML come from SGML, which contain tags, with similar syntax, HTML, and XML's biggest difference in: HTML is a set of tag language, which is described in an inherent tag to display web content. For example,
This is a qualified difference: the web page mixed data and display, while XML separates the data and display.
We look at the above example, in MyFile.htm, we only care about the page display method, we can design different interfaces, use different ways to type, but the data is stored in MyFile.xml, no change.
(If you are a programmer, you will be surprised to find that this is extremely similar to the idea of programming objects to objects! In fact, what is it not a program?)
It is this difference that makes XML convenient, efficient, and scalable on network applications and information sharing. So we believe that XML is an advanced data processing method, which will allow the network to span a new realm.
Sixth. XML strict format
The lesson brought about by HTML loose format, and XML adheres to the implementation of "good format" at the beginning.
Let's see some statements of HTML, these statements can be seen everywhere in HTML:
1.
Sample
2. Sample b> i>
3.
4. Samplar font>
In an XML document, the syntax of the above statements is incorrect. because:
1. All tags must have a corresponding end tag;
2. All XML tags must be reasonably nested;
3. All XML tags are case sensitive;
4. All marked properties must be used "."
So the correct way to write in the XML is
1.
Sample
2. Sample i> b> 3.
4. Samplar font>
In addition, the XML tag must follow the following naming rules:
1. You can include letters, numbers, and other letters in the name;
2. The name cannot be started with a number or "_" (underline);
3. The name cannot be started with the letter XML (or XML or XML ..);
4. The space cannot be included in the name.
Any errors in the XML document will get the same result: the web page cannot be displayed. Each browser developer has reached an agreement, and the XML is strictly discerning resolution, and any fine mistake will be reported. You can modify the above myfile.xml, such as "change
XML Version = "1.0" encoding = "GB2312"?>
myfile>
7. More about XML
Ok, now you already know:
1. What is XML;
2.XML, HTML, SGML relationship and difference;
3. XML simple application.
Congratulations! You have no longer known to XML, and have already taken the frontier of network technology. The whole learning process is not very difficult :)
If you have more interest in XML, I hope to learn more about XML details and other practical use technologies, please continue to browse our next chapter: XML concept