Some notes for beginners of XML

Source: Internet
Author: User
Almost every day, someone asks "What is XML", "What can XML do", "can XML do this for me", "What will XML replace", and so on. Since I have applied xml for a while recently, I want to talk about myself. some people have asked me every day about "what is XML" and "What can XML do ", "Can XML do this for me", "What will XML replace", and so on. As I recently used xml for a while, let's talk about my feelings. These experiences are very simple, and anyone who has used xml can have their own experiences. I am just passing through this path, confused about how I started, misinterpreted, and remembered, so I will share it with you.

I feel that beginners may come closer to the following misunderstandings:

1. is XML a substitute for HTML?

No. The well-written html should be a well-formed xml document, and it is better not to put them in a level of online comparison for other aspects.

2. is XML a substitute for databases?

No.

3. is XML a replacement?

None.

This conclusion may sound humorous: XML is a very important thing, but it cannot be replaced by anything.

But this is not surprising. some people compare it to the ASCII scale. they are the foundation of everything, but they do not (and do not need to) anything. (But just like ASCII, it replaces some character set definitions that are not big enough, and XML will also replace some data transmission specifications that you define in the exploitation, but there is nothing special in the mainstream .)

When I first started learning XML (or before I started learning it), I was most interested in the title: What benefits can XML be brought to me?

I think from a certain point of view, application XML is somewhat like application OO object-oriented:

-You can use it or not.
-If your use is very simple, it is not necessarily convenient to use it. if you use it, the consequences will be even worse.
-Compared with other practical things such as databases, MTS, and Web Server, it is more like a concept and a method.
-The larger the project, the greater the room for display and the greater the role.
-Once you understand the concept, even if you don't use xml parser, it doesn't affect your application, just as you can leave application OO in a specific language away.
-......

It seems more abstract.

Let's just give an example. For example, you would like to transfer some data between the two modules used by bbs:

-Spokesman
-Password
-Title
-Content

It is unrealistic to apply the four parameters, because you may need to expand the function at any time, for example, add

-Emoticon

And so on.

It is not possible to add a function each time, so the function is redefined.

So the simplest way is to combine them as a parameter and pass them to the function.

Before xml is available, you may apply the separator:

Str = 'spokesman = James; password = **; title = abc; content = XYZ'

Apply dictionary, collection, split, and other methods to the server to split them.

(Of course, you can define the object and structure by yourself, but in most cases, it must be a pure string-for example, another module is not developed by yourself .)

This method of passing strings has several titles, which are summarized into two major aspects:

1. accurate parsing is very troublesome. (For example, the title is "spokesman = James)
2. it is flat and has no hierarchical structure.

You can write some functions to solve these headers, such as making sure there are "spokespersons" and "passwords;

Write some functions to escape characters, and then write some functions to create hierarchical consequences...

Enough! Let's use XML. In my current familiarity:

-XML is used to transmit data.
-XML occupies the structure of these numbers-a tree structure
-Xml has a full set of methods to control this structure.
-The xml specification (or actual point, xml parser) helps you determine that the string you created is justified.
-There are measures in the xml specification (or actual point, xml parser) to verify this legitimacy
-For the server component that gets this string, you can use the ready-made Method in xml to hold it, which is xpath, pattern, similar to a T-SQL statement. (But remember that xml is a tree structure)
-XSLT uses xpath to convert xml (similar to DTS). one of the special cases is to convert XML into HTML output.


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.