Home  >  Article  >  Backend Development  >  XML easy learning manual (2) XML concepts

XML easy learning manual (2) XML concepts

黄舟
黄舟Original
2016-12-23 11:19:461570browse

Chapter 2 XML Concepts

Introduction

After the quick start of Chapter 1, you already know that XML is a language that allows you to create your own tags. It can separate data and formats from web pages. It can The ability to store and share data makes XML omnipotent. If you want to learn XML in depth and systematically master the ins and outs of XML, then we must first return to the concept of XML. XML (Extensible Markup Language), an extensible markup language. "Extensibility" "Identity" "Language". Each word clearly points out the important features and functions of XML. Let’s analyze it carefully:

1. Extensibility
2. Identification
3. Language
4. Structure
5. Meta data
6. Display
7. DOM

1. Extensibility---using XML, you You can create your own tags for your documents.

The first word of XML is "extensibility", which is why XML has powerful functions and flexibility.
In HTML, there are many fixed tags that we must remember and then use. You cannot use tags that are not in the HTML specification. In XML, you can create any markup you need. You can give full play to your imagination and give your documents some memorable tag names. For example, if your document contains some game guides, you can create a tag named , and then create , and other tags under according to the game category. You can create any number of markers as long as they are clear and easy to understand.

You may not adapt to it at first, because when we learn HTML, there are fixed tags that can be learned and used directly; (many people, including myself, build their own web pages while analyzing other people's codes and logos), XML, on the other hand, does not have any tags to learn, and few documents have exactly the same tags. what should we do? Haha, if not, just create it yourself. Once you actually start writing XML documents, you'll find that it's fun to create new tags as you like. You can create your own unique markup and even create your own HTML language.

Extensibility gives you more choices and powerful capabilities, but it also creates a problem: you must learn to plan. You need to understand your own document, know what parts it consists of, the relationship between them and how to identify them.

One thing to note about establishing identifiers is that identifiers describe the type or characteristics of data, such as , age , name , etc., rather than the content of the data, such as: <10pxl> ,<18>,, these are useless tags. If you have studied databases, you can understand it this way, an identifier is a field name.

2. Identification---Using XML you can identify elements in the document.

The second word of XML is "identification", which shows that the purpose of XML is to identify elements in the document.

Whether you are using HTML or XML, the essence of tags is to facilitate understanding. If there is no tag, your document will appear to the computer as just a long string, and every word will look the same, with no emphasis.

Through tags, your document is easier to read and understand. You can divide it into paragraphs and list titles. In XML, you can take advantage of its extensibility to create more appropriate tags for documents.

However, there is one thing to remind everyone: the logo is only used to identify information, it does not convey information itself. For example, this HTML code:

frist step
Here means bold. It is only used to indicate that the "frist step" character is displayed in bold. itself does not Contains any actual information, you can't see the on the page, it's the "frist step" that really conveys the information.

3. Language---When using XML, you have to follow a specific syntax to identify your documents.

The third word of XML is "language". This shows that as a language XML must follow certain rules. Although XML's extensibility allows you to create new identities, it still must follow a specific structure, syntax, and clear definitions.

In the computer field, language often refers to a "programming language", which is used to program to implement some functions and applications. However, not all "languages" are used for programming. XML is just a language used to define identifiers and A language for describing information.

Let’s take a deeper look at the basic principles of XML application. It may be boring, but it is important for the overall understanding. You can go through it quickly first, and you will have a vague concept in mind. The specific essence is It needs to be understood slowly in practice

4. Structure--XML promotes the structure of documents, and all information is arranged according to a certain relationship

."Structure" sounds too abstract. We understand it this way. Structure is to establish a framework for your document, just like writing an outline before writing an article. Structure makes your document look less disorganized and each part is closely connected to form a whole.

There are two principles of structuring:
1. Each part (each element) is related to other elements. The associated series form the structure.
2. The meaning of the logo itself is separated from the information it describes.

Let’s look at a simple example to help understand:


XML Easy Learning Manual
XML Quick Start
What is XML
Benefits of using XML

XML Concepts
< para>Extensibility Very clear:



...



The above document structure is also called It is a "document tree", the trunk is the parent element, such as , and the branches and pages are child elements, such as and .

5. Meta data (Metadata)---Professional XML users will use meta data to work.

In HTML, we know that we can use meta tags to define keywords, introductions, etc. of web pages. These tags will not be displayed on the web page, but can be searched by search engines and affect the order of search results.

XML deepens and expands this principle. With XML, you can describe where your information is. You can verify the information through meta, perform searches, force display, or process other data.

The following are some uses of XML metadata in practical applications:

1. Digital signatures can be verified to make online business submissions valid.
2. Can be easily indexed and searched more effectively.
3. Data can be transferred between different languages.

The W3C organization is studying a metadata processing method called RDF (Resource Description Framework), which can automatically exchange information. W3C claims that using RDF with digital signatures will enable "authentic and trustworthy" e-commerce to exist on the network.

6. Display

XMl alone cannot display the page. We use formatting technology, such as CSS or XSL, to display documents created by XML tags.

We mentioned in Chapter 1 that XML separates data and format. The XML document itself does not know how to display it, and there must be auxiliary files to help achieve it. (XML cancels all tags, including font, color, p and other style definition tags, so XML uses a method similar to CSS in DHTML to define document styles.), the file type used to set the display style in XML There are:

1. It itself is also based on XML language. Using XSL, you can flexibly set the document display style, and the document will automatically adapt to any browser and PDA (handheld computer).

XSL can also convert XML into HTML, so that old browsers can also browse XML documents.

2.CSS

Everyone is familiar with CSS. Its full name is Cascading Style Sheets, which is currently the main method used to display XML documents on browsers.

3.Behaviors

Behaviors have not become a standard yet. It is a unique feature of Microsoft's IE browser. You can use it to set some interesting actions on XML tags.

7.DOM

The full name of DOM is document object model. What is DOM used for? Assuming that your document is regarded as a separate object, DOM is the standard for how to operate and control this object using HTML or XML.

Object-oriented thinking method has become very popular. In programming languages ​​​​(such as java, js), object-oriented programming ideas are used. In XML, the web page is to be operated and controlled as an object. We can create our own objects and templates. To communicate with objects and how to command objects, you need to use API. The full name of API is Application Programming Interface, which is the rule for accessing and operating objects. DOM is an API that describes the rules of HTML/XML document objects in detail. It specifies the naming convention, program model, communication rules, etc. of HTML/XML document objects. In an XML document, we can think of each identification element as an object --- it has its own name and attributes.

XML creates identifiers, and the role of DOM is to tell script how to operate and display these identifiers in the browser window

We have briefly described some basic principles of XML above.

1.XML describes the data type. For example: "King lear" is a title element;
2.CSS stores and controls the display style of the element. For example: the title will be displayed in 18pt font
3.script script controls how the element behaves. For example: when a title element is "out of stock", it will be displayed in red.
4.DOM provides a common platform for the communication of scripts and objects, and displays the results in the browser window.

If there is an error in any part, you will not get the correct result.

The above is the content of XML Easy Learning Manual (2) XML concepts. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:XML easy learning manualNext article:XML easy learning manual