Combination of XML and HTML (below)

Source: Internet
Author: User
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:

Title ISBN Author

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.