In general, the result set we query from the database may be very large, so when the server returns to the client, the data will be divided into several pages for resolution transfer. In this case, use the DATAPAGESIZE attribute in the TABLE element
XML nesting
Generally, the result set we query from the database may be very large, so when the server returns to the client, the data will be divided into several pages for resolution and transmission. In this case, the DATAPAGESIZE attribute in the TABLE element can be used to specify the number of entries in the record set on each page.
For example:
Obviously, if the XML data pattern is symmetric, it will be good whether it is mapped to the ADO record set or bound to the table element. In actual use, there are also many examples of asymmetric XML data. for example, there may be more than one author in a book, which will cause some trouble in ING and binding. The solution to the title is to use nesting. Each row of table still corresponds to a primary element, and each column also corresponds to a child element. For repeated elements, nested tables are applied. Let's assume that in books. xml, the first book is Dean Straight, and the second is Charlotte Cooper, Shelley Burke, and Regina Murphy. The binding process is as follows:
● Create a TABLE element and assign the data Island ID to the Dataworks attribute;
● For separate XML elements, such Create a TD element and set the corresponding Dataworks attribute;
● For duplicate elements, a table is nested in the TD element;
● The Author information is displayed in a single row and single column.
Note that the Dataworks attribute must be set to "$ TEXT ",
To ensure that all contents of the nested element are displayed in the specified element.
The complete HTML code is as follows:
In fact, the best consequence of applying DSO is for structured symmetric data. the more effective way to process asymmetric data is to apply the DOM techniques we will first introduce in the future.
Use of DSO skills
1. visiting element attributes
Using DSO to visit the attributes of elements is very simple, you can directly process attributes by sub-element.
For example:
......
In this way, when bound to an HTML table, you can directly process it by sub-element:
If the attribute name is the same as the sub-element name, add "!" before the element name. . 2. Traverse record sets
DSO treats XML data Island as an ADO record set. one benefit is that it can use various methods provided by ADO to visit the data source, especially when you bind a data Island to HTML elements such as SPAN, DIV, and INPUT. These elements usually display the first record of the record set. to traverse and browse the record set, you can use the ADO method: Move, MoveFirst, MoveLast, MoveNext, and MovePrevious. For example, if you create a button response function, you can click "Next" to view corresponding records one by one.
For example:
Sub btnNext_onclick ()
Xmldso. RecordSet. MoveNext
End Sub
3. combined with the Script language
Some users prefer to write the Script language, and the DSO technique can also be well combined with various scripts.
For example (using VB Script as an example), the code for visiting the record set is as follows:
Dim rsBooks
Set rsBooks = xmldso. RecordSet
Value of the visit Field (child element:
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 DIV element named divTitle. the assignment code is as follows:
DivTitle. innerTEXT = sTitle
The script program can also process many DSO events. The following table lists some of these events:
The method FOR processing various events in a SCRIPT is to apply the FOR attribute in the SCRIPT label to specify the XML data Island ID, and apply the EVENT attribute to determine the EVENT type.
For example, to obtain the number of entries in a record set: