XML Easy Learning Handbook (i): XML QuickStart _xml/rss

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



the introduction of XML is getting hotter, 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 development trend, 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. The outline of this article 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: XML QuickStart I. 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. XML's strict format seven. More about XML. What is XML? This is often the first question, and often on the first question you will not understand, because most of the textbook answer: XML is extensible Markup language shorthand, 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: 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 to <head>,<table>, are in HTML 4.0 specification and definition, and XML allows you to create such a label, so called scalability.





Here are a few confusing notions to remind you that 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 write pages directly with XML. 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:





<?xml version= "1.0"?>


<myfile>


<title>xml Quick start</title>


<author>ajie</author>


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


<date>20010115</date>


</myfile>





Note: 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 one of the tags they create, which is not the same as HTML tags, For example, <title> here is the title of the article, <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? Look at the description of the organization of World 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 moreSimple, 4.XML easy to learn and create, 5.XML code will be clear and easy to read and understand, or 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're familiar with HTML, you'll find that the document is very similar to HTML, looking at the same sample 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 of <?xml version= "1.0"?> 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.


four child elements are defined below: Title,author,email, and date. Explain the title, author, mailbox and date of the article respectively. Of course, you can define these tags in chinese and it looks more understandable:





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


< articles >


< title >xml Easy Learning Manual </title >


< author >ajie</>


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


< 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 a 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.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 </title>
in HTML

</head>


<body bgcolor= "#FFFFFF" >


<b> title: </b>


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


<b> Author: </b>


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


<b> Mail: </b>


<span id= "email" ></span><br>


<b> Date:</b>


<span id= "date" ></span><br>


</body>


</html>





2. Save the following code as a 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, 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. XML and HTML differentiate between XML and HTML from SGML, which 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. The strict format of XML absorbs the lessons learned from the loosely formatted HTML format, where XML insists on a "good format" from the start.


We look at some of the HTML statements, which can be seen everywhere in HTML:


1.<p>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 statements are correctly written in XML as


1.<p>sample</p>


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


3.<td>sample</td>


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


Additionally, XML tags must follow the following naming conventions:


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


2. The name cannot begin with a number or "_" (underlined);


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


4. The name cannot contain spaces.





any errors in the XML document will get 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&gt, and then open myfile.xml with IE5, you will get an error message page:





<?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> Seven. More about XML well, by now you know: 1. What is XML; the relationship between 2.XML,HTML,SGML and the difference; 3.XML 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. (Source: Enet College)

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.