Home Web Front-end HTML Tutorial Complementary advantages between HTML and XML (Part 1)

Complementary advantages between HTML and XML (Part 1)

May 02, 2017 pm 03:08 PM

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:

<APPLET CODE=“com.ms.xml.dso.XMLDSO.class”
ID=“xmldso” WIDTH=0 HEIGHT=0 MAYSCRIPT=TRUE>
<PARAM NAME=“URL” VALUE=“myXML.xml”>
</APPLET>
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:

<HTML>

<XML ID=“xmldso”>

<?xml version=“1.0”?>

some XML……

</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:

<XML ID=“xmldso” SRC=“myXML.xml”>

</XML>
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:

<XML ID=“xmldso”>

<?xml version=“1.0”?>

<booklist>

<book>

<title>Straight Talk About Computers</title>

<isbn>72-80088-005</isbn>

</book>

<book>

<title> Gourmet Microwave </title>

<isbn>72-80081-082</isbn>

</book>

</booklist>

</XML>
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:

<p ID=title DATASRC=#xmldso DATAFLD=“title”></p>

<p ID=PRice DATASRC=#xmldso DATAFLD=“isbn”></p>
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:

<TABLE BORDER=1 DATASRC=“#xmldso”>

<THEAD>

<TR><TH>Title</TH>

<TH>ISBN</TH></TR>

</THEAD>

<TBODY>

<TR><TD><p DATAFLD=“title”></p></TD>

<TD><p DATAFLD=“isbn”>

</p></TD></TR>

</TBODY>
1
</TABLE>
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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles