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:
Title | ISBN | Author | |
---|---|---|---|
|
|
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:
……
In this way, when binding to an HTML table, you can process it directly by sub-element:
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:
Sub btnNext_onclick() xmldso.RecordSet.MoveNext End Sub
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”)
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
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
In addition to displaying record data, the script program can also quickly query, sort, and edit the record set. However, it should be pointed out that although ADO technology provides methods such as SortColumn and SortAscending to sort XML data, the effect is not as good as the sorting operation in XSL, so it is recommended that you make full use of XSL technology to realize this part of the function.
The remaining functions, such as using scripts to perform operations such as adding, deleting, and modifying record sets, or displaying HTML tables in pages, etc., are not explained here one by one. The usage is similar to the previous operations. Finally, it should be noted that all operations on DSO objects are completed on the user side, which is actually a copy of the server data object. The advantage of this is that it avoids the network from bearing the burden of large amounts of data communication. But at this time, any operations performed by the client have no impact on the data stored on the server. If you want to modify the server records, you must use the data exchange technology between the client and the server. We will discuss this in the future. Make an introduction.
The above is the detailed content of Complementary advantages between XML and HTML (Part 2). For more information, please follow other related articles on the PHP Chinese website!