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

Complementary advantages between XML and HTML (Part 2)

May 02, 2017 pm 03:12 PM

Generally, the result set we get from the database query may be very large, so when returning from the server to the client, the data will be divided into several pages and passed separately. At this time, you can use the DATAPAGESIZE attribute in the TABLE element to specify the number of recordset entries that each page contains.

For example:

<TABLE DATASRC=“#xmldso” DATAPAGESIZE=10>
Copy after login

Obviously, if the XML data format is symmetrical, whether it is mapped to an ADO recordset or bound to a table element, the effect will be good. In practical applications, there are many examples of asymmetric XML data. For example, a book may have more than one author, which will cause certain troubles in mapping and binding. The solution to the problem is to use nesting. Each row of the table still corresponds to a main element, and each column also corresponds to a sub-element. For repeated elements, nested tables are used. Let's assume that in books.xml, the author of the first book is Dean Straight, and the authors of the second book are Charlotte Cooper, Shelley Burke, and Regina Murphy. At this point, the binding process is as follows:

● Create a TABLE element and assign the data island ID to the DATAFLD attribute;

● For individual XML elements, such as , create a TD element, and set the corresponding DATAFLD attribute;

● For repeated elements, nest a table inside the TD element;

● Display author information in a single row and single column.

Note that the DATAFLD attribute here must be set to "$TEXT",

to ensure that the contents of the nested element are all displayed in the specified element.

The complete HTML code is as follows:

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

<THEAD><TR><TH>Title</TH>

<TH>ISBN</TH>

<TH>Author</TH></TR></THEAD>

<TBODY>

<TR><TD>

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

<TD><p DATAFLD=“isbn”>

</p></TD>

<TD>

<TABLE BORDER=0 DATASRC=“#xmldso” DATAFLD=“author”>

<TR><TD><SPAN DATAFLD=“$Text”></SPAN></TD></TR>

</TABLE>

</TD>

</TR></TBODY>

</TABLE>
Copy after login


In fact, the best situation when using DSO is for data with symmetric structure, while processing non- A more effective way to symmetric data is to use DOM technology which we will introduce later.

Application of DSO Technology

1. Accessing the attributes of an element

It is very simple to use DSO to access the attributes of an element. You can directly handle the attributes by sub-elements.

For example:

<book isbn=“9-001-122-12”>
……
</book>
Copy after login

In this way, when binding to an HTML table, you can process it directly by sub-element:

<TD><SPAN DATAFLD=“isbn”> </SPAN></TD>
Copy after login

If When the attribute name and sub-element name are the same, add "!" before the element name to distinguish them. 2. Traversing the record set

One of the great benefits of DSO processing XML data islands as ADO record sets is that you can use various methods provided by ADO to access the data source, especially when the data island is combined with something like SPAN, p When binding with HTML elements such as INPUT. Usually these elements display the first record of the recordset. If you want to traverse the recordset, you can use the ADO methods: Move, MoveFirst, MoveLast, MoveNext and MovePRevious. For example, if you create a button response function, as long as the user clicks the "Next" button, the corresponding records can be browsed one by one.

For example:

<XML ID=“xmldso” SRC=“books.xml”>
</XML>
Sub btnNext_onclick()
xmldso.RecordSet.MoveNext
End Sub
Copy after login

3. Combining with Script language

Some users are more accustomed to writing Script language, and the use of DSO technology can also be well combined with various Scripts.

For example (taking VB Script as an example), when accessing the record set, the code is as follows:

Dim rsBooks
Set rsBooks = xmldso.RecordSet
访问字段(子元素)的值:
Dim sTitle
sTitle = rsBooks(“title”)
Copy after login

You can use the innerText and innerHTML attributes to pass the obtained value to the HTML element . For example, there is a p element named pTitle, and the assignment code is as follows:

pTitle.innerTEXT = sTitle
Copy after login

You can also use scripts to handle many DSO events. The following table lists some of them:

The way to handle various events in a script is to use the FOR attribute in the

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.

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.

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