Recommend to XML beginners

Source: Internet
Author: User
Tags character set functions string xml parser xpath
Almost every day people ask "What is XML", "What XML can Do", "XML can do this for me",
"What will the XML replace" and so on. As a result of a slight use of XML for some time recently,
Let me talk about my feelings. These experiences are very simple, and anyone who has used XML has a lot of opinions,
But I just walked through this section of the road, the beginning of their own confusion, misunderstanding still remember clear, so take out and everyone
Share.
I think beginners may come close to the myth:
1. is XML a substitute for HTML?
No. Well-written HTML should be a well-formed XML document, and the other best not to
Compare them on a horizontal line.
2. is XML a database replacement?
No.
3. XML is not ... The replacement?
Not at all.
This conclusion may sound funny: XML is a very, very important thing, but it can't replace anything.
But it's not surprising that some people compare it to ASCII standards, they are the basis of everything, but there is no (and no need) to replace anything. (But just as ASCII replaces some of the character set definitions that don't have an amp), XML replaces some of the data transfer specifications you've defined in your application, but there's nothing particularly mainstream. )
One of my favorite questions when I first started learning XML (or before I started learning) was: What's the benefit of using XML?
I think that in some ways, using XML is somewhat like using OO object-oriented:
-You can use it, you can do without it.
-If your application is very simple, it may not be convenient to use it, and it might be worse with the effect.
-It's more like a concept than a database, Mts,web server, a method
-The larger the project, the greater the scope of its play.
-once really understood, even without the XML parser, it does not prevent you from using the concept, as you can put aside a specific language to use OO.
- ......
It seems more abstract, but not way it.
Let's just cite an example. Like you wanted to pass some data between two modules in the BBS application:
-spokesperson
-Password
-Title
-Content
Using four parameters is not realistic because you may want to extend the functionality at any time, such as adding a
-Facial symbols
Wait a minute
It is not possible to redefine a function every time you add a function.
So the easiest way is to combine them as a parameter to pass to the function.
Before you have XML, you may use delimiters:
str = "spokesperson = John; password =**; title =abc; Content =xyz"
Go to the server and take them apart using dictionary or collection or split.
(Of course you can define objects, structs, and so on, but in most cases it's a pure string-for example, another module is not developed by itself.) )
This method of passing strings has several problems, summed up in the two biggest aspects is:
1. It is troublesome to parse it correctly. (for example, the title happens to be "spokesperson = John;" Do
2. Is flat, no hierarchical structure
You can write some functions to solve these problems, such as to ensure that there must be a "spokesperson", "Password" and so on;
Write some functions to do the word escape, and then write some functions to create a hierarchical effect ...
That's enough! Let's use XML. In my current superficial understanding:
-XML is used to pass data
-XML gives the data a structure--a tree structure
-XML has a full set of ways to operate this structure
-XML specification (or actual point, XML parser) help you make sure that the string you created is legitimate
-The XML specification (or the actual point, XML parser) has the means to validate this legality
-For the server component that gets this string, you can manipulate it in an out-of-the-box way in XML, which is XPath, pattern, similar to a T-SQL statement. (but remember that XML is tree-structured)
-XSLT transforms XML (similar to DTS) using XPath, one of the special cases is the conversion of XML to 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.