XML and ASP simply combine to realize HTML template function _xml/rss

Source: Internet
Author: User
Tags html tags server memory
This paper uses the XML DSO data binding function to realize the separation of ASP code and HTML code, so as to realize the function of quickly changing the HTML template, because I just started to contact with XML, there are many do not understand, here is just a little idea, if this article has errors and omissions in the place please refer to more.

At present, the Quick Change template function is basically in replace the replacement template in the special label and then display, which increases the processing time of many ASP, and the template file is too long, Loading into memory for processing is also a test of server memory. In XML, a DSO data binding function is provided. The identity substitution operation can be delivered to the client. Because it is necessary to simplify the XML technology content of HTML templates.

In short, this approach is only implemented using the properties of the two HTML tags of datasrc and datafld. Nonsense is not much to say, all examples to speak. The following two examples will illustrate everything.

Example one: Single data display
The following is an ASP-generated XML data island.
<xml id= "XMLData" >
<xData>
<name>coder</name>
<webname> Brisk free Pearl </webname>
<weburl>http://blog.csdn.net/oyiboy</weburl>
</xData>
</xml>

HTML original code when displayed:
<table datasrc= "#xmldata" border=1>
<tr>
&LT;TD colspan=2> my Brief introduction </td>
</tr>
<tr>
<td> My name:</td>
<td><span datafld= "Name" ></span></td>
</tr>
<tr>
<td> website Name:</td>
<td><span datafld= "WebName" ></span></td>
</tr>
<tr>
<td> website Address:</td>
<td><a datafld= "Weburl" ><span datafld= "Weburl" ></span></a></td>
</tr>
</table>


Example two: multiple data display
The following is an ASP-generated XML data island.
<xml id= "Xmldatalist" >
<xData>
<webList>
<webname> Brisk free Pearl </webname>
<weburl>http://blog.csdn.net/oyiboy</weburl>
</webList>
<webList>
<webname>estyle (Shida) The wild fantasy hand tie </webname>
<weburl>http://blog.csdn.net/estyle</weburl>
</webList>
<webList>
<webname> Favorite Cabbage </webname>
<weburl>http://blog.csdn.net/qunluo</weburl>
</webList>
</xData>
</xml>

HTML original code when displayed:
<table datasrc= "#xmldataList" border=1>
<thead>
<tr>
&LT;TD colspan=2> My focus on CSDN blog list </td>
</tr>
<tr>
&LT;TD align= "center" > Name </td>
&LT;TD align= "center" > Address </td>
</tr>
</thead>
<tbody>
<tr>
<td><span datafld= "WebName" ></span></td>
<td><a datafld= "Weburl" ><span datafld= "Weburl" ></span></a></td>
</tr>
</tbody>
</table>

(The above two examples can be copy to a file to see the actual running effect.)
Note that the thead and tbody in the HTML source code are useful when displaying multiple records, and if you don't understand what they have to do with them, see what happens.

By the way, the image and the key data binding and hyperlink binding is similar, such as: and <button datafld= "ButtonValue" ></button>

Limitation is the need for browsers to support XML, as well as a question. <a datafld= "Weburl" ><span datafld= "Weburl" ></span></a> Shows the effect of the <a href= "Http://blog.csdn.net/oyiboy" >http://blog.csdn.net/oyiboy</a> if you want to implement the XML data without modifying it <a href= "Http://blog.csdn.net/oyiboy/?loginname=code" >http://blog.csdn.net/oyiboy</a> The effect should be how to do. Please give me an expert advice.
Related Article

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.