Optimizing two times retrieval with XML

Source: Internet
Author: User
Tags add object include interface sql object model tag name xsl
xml| optimization
In the search engine design and similar software function design, an essential function is: To have the search results of two retrieval. If the retrieved dataset is static (for example, in a database), the usual practice is to dynamically add new constraints on the basis of existing search conditions. However, to reconstruct the constraint conditions of data retrieval, users often need to interact with the server again and download the required dataset to merge the output again. If you can retrieve the downloaded data collection two times on the client, it will greatly reduce the burden on the Web server and the database server.
XML can meet the above requirements to a large extent. It separates the data content itself from the data display format and handles it separately. This way, if you need to change the way the document is displayed, just modify the style file (XSL). The self-describing nature of XML can well represent many complex data relationships, enabling xml-based applications to search for relevant data content accurately and efficiently in XML files, ignoring other unrelated parts. At the same time, the entire data operation is completed on the client, greatly reducing the burden on the server.
Introduction to XML Programming interface DOM
The DOM (Document Object model) is a platform-and language-independent programming interface that allows programs and scripts to dynamically access and modify the content structure and type of a document. It defines a series of objects and methods to perform various random operations on the nodes of the DOM tree.
Document object: Is the topmost node of the DOM tree and is the portal that operates on the entire document.
Element and attr objects: These node objects are maps of parts of a document, and the hierarchy of nodes reflects the structure of the document.
Text object: As a child of the element and attr object, the text object expresses the textual content of the elements or attributes. The text node no longer contains any child nodes.
Collection index: DOM provides a variety of collection indexing ways in which nodes can be traversed in a specified manner.
The DOM describes the content and structure of an XML document using a series of interfaces described above, that is, using objects to model documents. The basic features of this object model implementation include:
An interface that describes the presentation and operation of documents;
The behavior and attributes of the interface;
Interfaces and interoperation.
The DOM parses structured XML documents, and all individuals in the document, such as elements, entities, attributes, and so on, can be represented by the object model. The logical structure of the entire document resembles a tree, and the resulting object model is the node of the tree, each containing both methods and attributes. DOM provides a number of ways to find nodes. The methods used for searching are:
Search for elements by tag name: Use the getElementsByTagName method in the Document object to find elements in the full-text scope;
Searching for nodes using XSL mode: All types of nodes have selectnodes methods, which can be invoked to find nodes using the XSL pattern matching strategy;
Use the collection index to search for nodes: Index parameters are counted starting at 0, such as child nodes ChildNodes object sets.
With DOM, developers can dynamically create XML, traverse documents, and add (delete/modify) document content. DOM provides APIs that have nothing to do with programming languages, so there may be a difference in how different parsers are implemented for interfaces that are not explicitly defined in some DOM standards. The example in this article uses the MSXML DOM scheme and uses IE 5.0 as the output display browser.
Software implementation
The following is a simple student performance query system as an example to specify how to achieve. You can query the student's score by the student's class, and then you can select a list of students with an average score higher than the set score (with a text box to receive the set score).
Include a student score form in SQL Server with key fields: Student name (name), Class (Class), single score (Yuwen, Shuxue, Jisuanji, Yingyu, etc.), average score (averagescore).
First, edit the initial page to provide the ability to query student performance by class.
<form method=post Action=myrearch. Asp>
Enter class Number: <input type=text name=classname>
<input type=submit value= "Submit" ><input type=reset value= "Refill" >
</form>
myrearch.asp file, provides two query functions by average score query. The key code is as follows:
<%@ Language=vbscript%>
Establish a database connection and retrieve all the required data sets from the database according to user requirements
<% Set conn=server.createobject ("Adodb.connection")%>
<% Set Rs=server. CreateObject ("Adodb.recordset")%>
<% Conn. Open application ("SQL Server
Conn ")%>
<% sqltext= "SELECT * from scoretable where class= '"%>
<% Sqltext=sqltext & Request. Form ("ClassName") & "%>"


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.