Give XML beginners

xiaoxiao2021-03-06  119

[Simple] Almost someone asked "What is XML", "What can be doing XML", "XML can do this for me", "XML will replace what" and so on. Since I use it for XML for a short period of time, I will talk about my feelings. These experiences are very shallow. Anyone who has used XML has, and seeing the benevolence, but I just got through this road, confused by myself, misunderstanding reminded, so I will share it with you. Almost someone asked "What is XML", "XML can do", "XML can do this for me", "XML will replace what" and so on. Since I use it for XML for a short period of time, I will talk about my feelings. These experiences are very shallow. Anyone who has used XML has, and seeing the benevolence, but I just got through this road, confused by myself, misunderstanding reminded, so I will share it with you.

I think beginners may approach the misunderstanding:

1. Is XML is an alternative to HTML?

Not. Write HTML should be a Well-Formed XML document, and others do not put them on an horizontal line.

2. Is XML is not a replacement of a database

Not.

3. Is XML is ...

neither.

This conclusion may be very funny: XML is very very important, but it can't replace anything. But this is not surprising, some people make it better than the ASCII standard, they are all based on everything, but there is no (nor need) to replace anything. (But as ASCII replaces some character set definitions that do not have a larger, XML will replace some data transfer specifications you defined in your application, but there is nothing special mainstream.)

When I started learning XML (or not started), I was definitely: What benefits can I bring to me?

I think some angle saying that some pictures of using an oo are object-oriented:

- You can use it, you can also use it.

- If your application is very simple, it is not necessarily convenient to use it, and the effect will be worse.

- Compared with other actual things such as databases, MTS, Web Server, it is more like a concept, a method

- The larger the project, the greater the room, the greater the role.

- Once you really understand, even if you don't have to use XML Parser, you don't hinder your use of this concept, as you can use OO.

- ...

It seems to be more abstract, there is no spectrum.

Then give an example. For example, you have wanted to pass some data between the two modules in the BBS application:

- Speaker

- Password

- Title

- Content

It is not realistic using four parameters because you may have to extend function at any time, such as adding

- Emoticons

and many more

It is impossible to redefine a function of each time each time you add a function.

So the easiest way is to combine them as a parameter to the function.

Before you have XML, you may use a separator:

Str = "spokesperson = Zhang three; password = **; title = ABC; content = xyz"

Use Dictionary or Collection or Split and so on to Server.

(Of course, you can define objects yourself, structure, etc., but in most cases, it has to be a pure string - such as another module is not developed.) This method of passing string has several problems, summarizes two The biggest aspect is:

1. The correct parsing it is very troublesome. (For example, the title is just a spokesman = Zhang 3; "What to do)

2. It is a flat, there is no layered structure

You can write some functions to solve these problems, such as making sure there must be "spokesperson", "password", etc.; write some functions to make a character escape, then write some functions to create a hierarchical effect ...

enough!咱 咱 吧 吧. In my current understanding:

- XML ​​is used to transmit data

- XML ​​makes these data - a tree structure

- XML ​​has a full set of operations this structure

- XML ​​specification (or actual point, XML Parser) helps you determine that the string you created is legal

- A method for verifying this legitimacy in the XML specification (or actual point, XML Parser)

- For Server Components that get this string, you can use the ready-made method in XML.

This is XPath, Pattern, similar to the T-SQL statement. (But remembering XML is a tree structure)

- XSLT uses XPATH to convert XML (similar to DTS), one of which is converted to HTML output.

转载请注明原文地址:https://www.9cbs.com/read-101953.html

New Post(0)