Who is the twin brother of HTML? There is no doubt that XML, as a pair of twins, is similar to the two basic syntaxes, but external and internal are not equivalent. Although XML is similar to HTML, there are essential differences between them. Who is the twin brother of HTML? There is no doubt that XML, as a pair of twins, is similar to the two basic syntaxes, but external and internal are not equivalent. Although XML is similar to HTML, there are essential differences between them.
I. XML and HTML
XML (eXtensible Markup Language) is an eXtensible Markup Language. it is similar to the HTML syntax and belongs to the Markup Language. How can we differentiate them?
1. design differences
XML is designed to transmit and store data, with the focus on data content. HTML is designed to display data, with focus on the appearance of data. HTML is designed to display information, while XML is designed to transmit information.
2. syntax differences
(1) The HTML format is diverse. some of the tags can appear in pairs. XML requires that all tags appear in pairs;
(2) HTML tags have limited fixed styles. XML can be expanded in any way, and the tag type can be customized;
(3) HTML can have multiple Tag headers. XML can have only one tag header;
(4) HTML tags are case-insensitive and XML tags are case-sensitive.
II. XML explanation
I remember no system configuration document used for system development. Yes, it is an xml document. As the system configuration file is the main application of xml, it can also be used in Ajax or Web Services to transmit data.
1. XML history
Before learning about the basic usage of XML, let's take a look at the development history of the markup language.
The predecessor of XML is SGML (The Standard Generalized Markup Language), which is also optimized based on HTML. SGML is a standard after the GML specification, but SGML is a very rigorous text description method that is too large and complex to understand. At the same time, W3C (World Wide Web Alliance) also found HTML problems, such as: it cannot explain other forms of content such as audio and video files and chemical formulas, and its performance is poor and not easy to expand, and poor elasticity. To solve the above problems, experts used SGML for simple production and developed XML based on HTML development experience.
2. XML usage
First look at an XML instance
Copy XML/HTML Code to clipboard
<书籍列表>
<计算机书籍>
<
>
39.00
<书籍列表>
<计算机书籍>
Oracle应用大全《《《》》》‘’;;‘’“”
39.00
<计算机书籍>
Java Application Overview
39.00
2.1 Statement
A well-formatted XML file must begin with an XML declaration, that is, It provides basic information about the document. Encoding indicates the character encoding method used by the XML file. the encoding format of the XML file to be saved must be the value of encoding.
Elements 2.2
The element is the start tag, end tag, and all content between the two.
Similar to HTML, XML also has a basic tag structure. the tag format is the same as that of HTML. The difference is that an end tag must exist when an XML tag has a start tag, it is case sensitive. It allows the label format to be nested, but must be correctly nested.
The XML structure is a tree structure with only one root element and other elements embedded in the root element. For example, in the previous example It is the root element.
2.3 entity reference
Entity References print some special symbols in XML documents in a specific format, similar to the text in CDATA to be mentioned below.
Copy XML/HTML Code to clipboard
<书籍列表>
<计算机书籍>
<
>
39.00
Basic object references are not detailed.
2.4 Special labels
CDATA is a special label that enables all content in it to be printed and output in the form of text. The format is as follows:
Copy XML/HTML Code to clipboard文本内容
<书籍列表>
<计算机书籍>
Oracle应用大全《《《》》》‘’;;‘’“”
39.00
<书籍列表>
2.5 Miscellaneous
(1) XML documents are structured in a tree with diagrams, and IE is often used for display;
(2) attribute values in XML tags must be enclosed by quotation marks (single or double quotation marks, but must be consistent );
(3) in XML documents containing complex internal structures, you can use the xsl format to beautify xml display. format: .
3. Note
1. a statement is required: ;
2. During saving, you need to save the data type according to the encoding type in encoding. do not forget to select the storage type during saving;
3. there is only one top element;
4. case sensitive;
5. attribute values must be enclosed by quotation marks (single or double quotation marks );
6. start and end;
7. the nested form should be correct.
We have discussed the basic application of XML. XML is simple. Is XML just like this? Of course not. it can be seen from its basic name that it is also a programming language, so it should have some features of the programming language, such as templates in some languages or APIs in Java. Yes, XML can also define its own syntax structure. it can write template functions like programming languages, but in XML it is called legal XML, it is the legal XML that has been verified by DTD or Schema.
The above is a detailed introduction to the basic concepts of XML. For more information, see other related articles in the first PHP community!