Using PHP and XML for website programming

Source: Internet
Author: User
Tags object model php and xpath xsl

First, small sequence

HTML is easy to learn and general, the general PHP program is embedded in the HTML language implementation. But as the web becomes more widely used, the weakness of HTML is becoming more and more obvious. The advent of XML, which compensates for these deficiencies, provides a common way to handle all the data on the Internet.

Second, the limitations of HTML analysis

1, the scalability of HTML is poor. Although HTML should suffice as a general application, the HTML has obvious drawbacks when dealing with symbols such as math and chemistry, and it cannot be extended, which greatly limits its development.

2, link loss can not be automatically corrected. Because the URL address of the Web page often changes, and changes the URL address must manually modify this information, otherwise you will encounter the "404URL address not Found" information, which greatly increased the maintenance of the Web page workload.

3, the data search for a long time. Because HTML is used primarily to control the display of a Web page, the same data has different storage formats in different Web pages, which makes it impossible to quickly find the data when it is searched.

4, HTML for Double-byte or multi-state text support is not enough. For example, the Chinese information page will appear in different platforms can not be displayed and so on.

It is because of these shortcomings that people have studied web page making languages that can replace HTML. These are already in use: Extensible Markup Language XML, cascading style sheets (CSS), and Dynamic HTML (DHTML).

Iii. Composition of XML

Here are a few key XML technologies:

1. DTD (document type Declaration)

The main function of the DTD is to define the content schema of the XML, limit the data range of the XML markup, and define the data type of the property. However, because it is not written in XML, extensibility is poor, and only a limited number of data types are available, so its role is limited.

2. XML Schema

The XML schema works like a DTD. But the difference is that the schema file describes the specific type of elements and attributes in the XML file that references it. In addition, because it is written in XML, schemas and DTDs compare with the following advantages:

· The XML schema content model is open and can be expanded at will, and the DTD cannot parse the expanded content.

· A DTD can only define a content type as a string, whereas an XML schema allows content types to be defined as integers, floating-point types, booleans, or many other simple data types.

· XML Schemas use namespaces to associate a particular node in a document with a schema, an XML file can have multiple schemas, and an XML file can have only one DTD.

3, XLink

As a Web language, the ability to link XML is very important. The linking and addressing mechanisms for XML include XLink, XPath, and XPointer. XLink provides a powerful link method that allows you to establish one-way or multi-directional complex connections between documents, as well as a variety of link functions such as annotation links, profile links, extended link sets, and more. XPath is used in XSLT and xpointer to support positioning relative to nodes and node sets in XML documents. XPointer provides a location for the internal structure of the content of an XML document, such as a string or a selected paragraph, on the basis of XPath. The ability to link XML is greatly enhanced than HTML.

4. CSS and XSL

One of the great features of XML is the separation of content from formatting, which means that the XML document does not contain information about how to display/represent the document. CSS and XSL (XML Style Language) solve the problem of displaying XML documents.

CSS (cascading style sheets) can also be used in HTML and XML. XSL fully uses XML syntax, and functionality is much more powerful than CSS.

5, DOM

The Document Object Model (DOM) is a platform-and language-independent program interface that provides the means to dynamically access and update the content, structure, and style of a document. The text can be treated as further processing and the results of the processing are updated to the presentation page.

The goal of DOM is to define a standard programming interface for XML and HTML, which includes the core, HTML, and XML three parts. The core of the DOM establishes a set of underlying objects that can represent any structured document. HTML and XML provide a high-level interface that can be used as a more convenient document view. The DOM specification consists of objects and methods. Programmers use them to make it easier to access and manipulate specific types of documents.

6, namespaces

Namespaces is a collection of all names that are distinguished by URLs and that appear in the elements and attributes of an XML file. In XML, users can define tags and elements themselves. Therefore, if you combine multiple XML files into one, there is a good chance of conflict. namespaces solved the problem.

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.