I. Small order
HTML is easy to learn and common. Common PHP programs are embedded in the HTML language. However, as WEB applications become more and more widely used, the weakness of HTML becomes more and more obvious. The emergence of XML makes up for these shortcomings. It provides a common method to process all data on the Internet.
Ii. Limitations of HTML
1. Poor HTML scalability. As a general application, HTML should be enough, but HTML has obvious disadvantages when dealing with symbols such as mathematics and chemistry, and it cannot be expanded, in this way, its development has been greatly restricted.
2. The link cannot be automatically corrected after it is lost. Because the URL address on the Web page changes frequently, you must manually modify the information when changing the URL address. Otherwise, the information "404URL address not found" is displayed, this greatly increases the web page maintenance workload.
3. Long data search time. HTML is mainly used to control the display of web pages. As a result, the same data has different storage formats on different web pages. In this way, you cannot quickly find the desired information during data search.
4. HTML does not support double-byte or multi-country text. For example, the Chinese information page cannot be displayed on different platforms.
Due to these shortcomings, people have studied the Web page production language that can replace HTML. Some of them have been put into use: extensible markup language XML, Cascading Style Sheets (CSS), dynamic HTML (DHTML), and so on.
Iii. XML Composition
Here we will briefly list several major XML technologies:
1. DTD (document type declaration)
The main function of DTD is to define the content mode of XML, limit the data range marked by XML, and define the data type of attributes. However, because it is not written in XML, it has poor scalability and only provides several limited data types, so its role is limited.
2. XML Schema
The role of XML Schema is similar to that of DTD. However, the difference is that the Schema file describes the specific types of elements and attributes in the XML file that references it. In addition, because it is written in XML, Schema has the following advantages over DTD:
· The XML Schema content model is open and can be expanded at will, while the DTD cannot parse the expanded content.
· DTD can only define the content type as a string, while XML Schema can define the content type as integer, floating point, Boolean, or many other simple data types.
· XML Schema uses Namespaces to associate special nodes in the document with the Schema. an XML file can have multiple corresponding schemas, and an XML file can have only one DTD.
3. XLink
As a Web language, the link capability of XML is very important. XML links and addressing mechanisms include XLink, XPath, and XPointer. XLink provides powerful link methods to establish one-way or multi-direction complex links between documents, as well as annotation links, summary links, extended link sets, and other link functions. XPath is used in XSLT and XPointer. It supports locating relative nodes and node sets in XML documents. Based on XPath, XPointer provides positioning for the internal structure (such as a string or a selected paragraph) of the content of the XML document. The link capability of XML is greatly enhanced than that of HTML.
4. CSS and XSL
A major feature of XML is the separation of content and format. That is to say, XML documents do not contain information about how to display/represent documents. CSS and XSL (XML Style Language) solve the XML document display problem.
CSS (stacked style sheet) can also be used in HTML and XML. XSL fully uses the XML syntax, which is much more powerful than CSS.
5. DOM
The Document Object Model (DOM) is a platform-and language-independent program interface that provides a means to dynamically access and update the content, structure, and style of a document. The text can be further processed and the processing result is updated to the presentation page.
The purpose of DOM is to define a standard programming interface for XML and HTML, which includes three parts: Core, HTML, and XML. The core part of DOM is a set of underlying foot bath powder object sets, which can represent any structured documents. HTML and XML provide high-level interfaces for convenient document views. DOM norms consist of objects and methods. Programmers can use them to more easily access and operate on specific types of foot bath powder documents.
6. Namespaces
Namespaces is a set of all the names in the elements and attributes of the XML file that are differentiated by URLs. In XML, you can define tags and elements by yourself. Therefore, if you merge multiple XML files into one, conflicts may occur. Namespaces solves this problem.
Iv. XML support for PHP
PHP provides powerful support for XML. It uses an XML "parser" and provides 20 (PHP4) XML parsing functions to support this parser. Below are some of the most common PHP parsing functions.
1. xml_parse
Boolean xml_parse (int parser, string data, int [isFinal]);
This function is used to Parse Files in XML format. The parser parameter is the parsing code. The parameter data is the parsed data block (chunk ). The isFinal parameter can be omitted. If it is set to true, the system automatically sends the final part of the foot bath powder (piece) to the data parameter. If no error exists, true is returned.
2. xml_parser_create
Int xml_parser_create (string [encoding]);
This function is used to initialize a New XML parser. The encoding parameter can be omitted, is the character set used by XML, the default value is ISO-8859-1, there are other US-ASCII, UTF-8 two. If the call succeeds, the parser code is returned for other functions. If the call fails, false is returned.
3. xml_set_element_handler
Boolean xml_set_element_handler (int parser, string startElementHandler, string endElementHandler );
This function configures the element header for the xml_parse () function. The parser parameter is the parsing code. The startElementHandler and endElementHandler parameters are the element start and end headers respectively. The startElementHandler must include the parsing code, name, and attribute. The endElementHandler parameter includes two parameters: parse the FA powder code and name. If no error exists, true is returned.
4. xml_set_character_data_handler
Boolean xml_set_character_data_handler (int parser, string handler );
This function configures the character data header. The parser parameter is the parsing code. The handler parameter contains two elements: parsing code and data string. If no error exists, true is returned.
5. xml_get_error_code
Int xml_get_error_code (int parser );
This function can obtain the error code for XML processing. The parser parameter is the parsing code. If a parser error occurs, false is returned. Otherwise, error code (such as XML_ERROR_BINARY_ENTITY_REF...) is returned ).
6. xml_error_string
String xml_error_string (int code );
This function can obtain the error code of the font during XML processing. The parameter code is the parsing error code. If no error is returned, the return value is a text description string of the Code.
7. xml_get_current_line_number
Int xml_get_current_line_number (int parser );
This function is used to obtain the row number currently being processed by XML parsing. The parser parameter is the parsing code. If the parser has an error, false is returned. If no error exists, the row number of the full bath powder is returned.
8. xml_parser_free
Boolean xml_parser_free (int parser );
This function is used to release the memory currently used for XML parsing. The parser parameter is the parsing code. If no error exists, true is returned. Otherwise, false is returned.