One simple XML tutorial

Source: Internet
Author: User
In the early days of Intel, AndyGrove met an employee who suggested the company to develop a personal computer based on the chip. AndyGrove asked, "What is personal computing performance ?", This employee, for example, can store prescriptions. Grove considers all research In the early days of Intel, Andy Grove met an employee who suggested the company develop a personal computer based on the chip. AndyGrove asked, "What is personal computing performance ?", This employee, for example, can store prescriptions. Considering that all research, development, and market use require millions of US dollars, Grove decided to provide traffic lights to chips as the beginning. Everyone is Zhuge afterwards. Andy Grove, no matter how you look at him, is widely regarded as a very intelligent person-able to make major decisions for developing a company. However, in 1970s, it was impossible for him to predict the potential of a personal computer. If he saw Excel, Quark, Photoshop, Oracle, or the Internet, he would
Knowing how to put a strong processor on the desktop will promise the software to do anything.

But if you haven't seen it with your own eyes, who can think of it. In the era of typewriter, addition machine, and pencil as computing tools, can you describe PC and its usefulness?

This example can be used to describe the extended Markup Language (XML-eXtensible MarkupLanguage. There is nothing similar to it, so it is difficult to compare it. You may have heard that XML is an HTML modifier or is similar to HTML. you can define your own tokens. These two statements are not all true, just as PC is a storage
Machines are the same.

My mom is a cook who practices NLP. if I use her recipe, my family will save a lot of money.

I started with a brief introduction. So I opened the text editor and started to write some HTML code:

Recipe

Chocolate Chip Bars

After writing the above lines, I want to write my mom's exquisite recipes. How can this problem be solved? An old-fashioned Web page. What about next? Send the URL of my page to people who are interested in this recipe and ask them to remove

And? It takes some time for me to get the actual content.

Take a look at the following possible XML markup:

Carol Schmidt

Chocolate Chip Bars

In XML, the tag can best describe the content. In this way, I can determine whether any search is displayed in "Chocolate Chip" in the tag can all get mom's recipe. Further, if my information is copied by a token (meaningful tag) like this-I can tell other programs how to apply them. I can also encode The content in the tag is put into a database domain, and then output to a hard copy of a book. Also, I can use a word processor supporting XML to make web page publishing easy.

This is the essence of XML: enable the tag owner and the machine to read. But before achieving this goal, we should understand what is involved in XML encoding.

To organize a good XML file, the document must meet two requirements: good and effective. We started with a well-organized document.

I have invented some specifiers that describe recipes and organized them into a cool and readable method. It may not be the best tag, but it works well in the following example.




Carol Schmidt
Chocolate Chip Bars
Dinner
Dessert


2/3 C butter
2 C brown sugar
1 tsp vanilla
1 3/4 C unsifted all-purpose flour
1 1/2 tsp baking powder
1/2 tsp salt
3 eggs
1/2 C chopped nuts
2 cups (12-oz pkg.) semi-sweet choc. chips


Preheat oven to 350 degrees. Melt butter;
Combine with brown sugar and vanilla in large mixing bowl.
Set aside to cool. Combine flour, baking powder, and salt;
Set aside. Add eggs to cooled sugar mixture; beat well.
Stir in reserved dryingredients, nuts, and chips.
Spread in greased 13-by-9-inch pan.
Bake for 25 to 30 minutes until goldenbrown;
Cool. Cut into squares.



This is an XML document that can be received-tell you what XML is: organize data in a practical way.

Although these tokens look a bit like HTML, there is a big difference: The file does not point out how the data is represented. Layout commands are displayed from other places when we are ready. This is the same as putting the address book information in the fields and records of the database, rather than in the list generated by the word processor. The database allows you to combine the information in the address book into tags, envelopes, letters, or any other carrier. Finally, the recipe file is merged into a language, such as HTML or CSS.

As mentioned earlier, XML documents must be well organized. This means that the file must meet the following three basic rules:

Document defined in XML Start. There is a root element that contains all other content, as shown in the above example And Identifier. All elements must be fairly nested without cross-nesting. In the above example Elements are fairly nested And Mark. However, the following Mark has a serious title:

Chocolate chips

Therefore, 'Chocolate chips 'is not included in the ingredients list. Therefore, this document is not organized properly. This may be nothing in HTML, because the browser has been designed to handle this title.

But it is fatal in XML-the application will reject all the unorganized files.

We now know that it is very important to be well organized, but more than that.



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.