Complementary advantages between HTML and XML (Part 1)

零下一度
Release: 2017-05-02 15:08:09
Original
1646 people have browsed it

Currently, the content data of many Web sites are stored in databases or data files. For Web program developers, if they want to extract useful information from the database, the traditional method is to write scripts on the server side (such as VBScript, javaScript, CGI, asp, Perl, etc.) and execute the database The SQL query obtains relevant records, and then organizes the query results into HTML pages and returns them to the client. The user uses the browser to observe the final results.

In order to improve the flexibility and scalability of system services and enable a wider range of service targets, many commercial websites try their best to provide business rules, original data and presentation forms as independent services. HTML's way of embedding data in display obviously does not meet this need. Therefore, storing original data in XML documents and using style sheets to display content are the advantages of XML technology suitable for e-commerce. But in essence, XSL technology is not oriented to data display. It is a format conversion technology that is far less rich than HTML in terms of display means and methods. For programmers, a more ideal solution is to combine the two technologies of HTML and XML to complement each other's advantages, so that the real original data can maintain its original meaning and structure while making full use of the ever-changing display of HTML. Skill. XML Data Island is the product of this technology fusion. It uses the tag to embed XML data directly into HTML pages, thus realizing the complementary advantages of the two.
How to handle data islands in IE

In order to be able to handle this kind of HTML page with embedded XML code, Internet Explorer 4.0 (hereinafter referred to as IE 4.0) introduced DSO (Data Source Objects, data source objects) Technology, implemented using Java Applet.
For example:



Copy after login

In the above example, the CODE attribute specifies the DSO Java applet, the MAYSCRIPT attribute ensures that the user-side script can process the data object, and the PARAM tag specifies the location of the XML document.

The limitation of using Java is that it can only describe the URL address of XML in the HTML document, but cannot directly embed the XML tag into it. This is still far behind the real data island solution. Microsoft has expanded DSO technology in Internet Explorer 5.0 (hereinafter referred to as IE 5.0), breaking through previous limitations and truly integrating HTML and XML. HTML pages support direct use of tags.

For example:







some XML……

Copy after login


As long as the ID of each data island is unique, you can embed data islands wherever necessary in the page, and these DSOs are independent of each other.

In addition to the direct embedding method in the above example, you can also use external references to link data islands.

For example:



Copy after login

In this way, only when the company's customer objects continue to use IE 4.0, and in order to solve the compatibility problems of these customers, Java Applet is what programmers need. Options to consider.

In the DSO technology implemented by IE 5.0, if the data is the result of querying the database through SQL language, then they are stored in the ADO (ActiveX Data Objects) record set. The server sends this ActiveX control (usually an ADO recordset) to the client, where the client script program performs further processing. In fact, IE 5.0 handles XML data islands as a special ADO record set.

XML data binding

1. ADO recordset mapping

Every main element in XML is mapped to a record in the ADO recordset, and the sub-elements are correspondingly mapped to fields in the recordset (also called domains).

For example, the XML data island books.xml exists as follows:









Straight Talk About Computers

72-80088-005





 Gourmet Microwave 

72-80081-082





Copy after login


At this time, the mapped ADO record set is:

title isbn

Straight Talk About Computers 72-80088-005

Gourmet Microwave 72-80081-082

2. Binding to HTML elements

After embedding the data island in the HTML document, you can bind the XML data island to the HTML element. Each DSO entry (ie, data island) has a unique ID number. First, set the DATASRC attribute in the HTML element to the corresponding ID to associate the HTML element with the data island. Then determine the extracted XML element by setting the DATAFLD attribute value.

For example, the code bound to the p element is as follows:

Copy after login

Note: Not all HTML elements can be bound to XML data islands. Currently, the elements that support this DSO binding mechanism are as follows:

A, APPLET, BUTTON, p, FRAME, IFRAME, IMG, INPUT (the types here are: CHECKBOX, HIDDEN, LABEL, PASSWord, RADIO and TEXT), LABEL, MARQUEE, SELECT, SPAN, TABLE and TEXTAREA.

3. Explicit XML data in tabular format

If XML data is bound to the TABLE element, it can be automatically displayed in a multi-row tabular format.

For example, the code for binding XML data to TABLE elements is as follows:


1
Title ISBN

Copy after login


这样,通过将TABLE元素中的DATASRC属性设定为#xmldso,把两者绑定起来。表格内部分为表头(THEAD)和表体(TBODY)两部分。每一个元素都会显示为一行表格,具体每一栏显示哪一项数据,则由p元素中的DATAFLD属性指定。                        

The above is the detailed content of Complementary advantages between HTML and XML (Part 1). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!