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>
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
● 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>
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>
In this way, when binding to an HTML table, you can process it directly by sub-element:
<TD><SPAN DATAFLD=“isbn”> </SPAN></TD>
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
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 <script> tag to specify the XML data island ID, and use the EVENT attribute to determine the event type. <br/><br/>For example, to get the number of entries in the record set: <br/></script>
<SCRIPT Language=“VB Script” FOR=“xmldso” EVENT=“onDataAvailable”> lblRecords.value = booklist.RecordSet.RecordCount </SCRIPT>
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!

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools