xml| templates
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>
<table datasrc= "#xmldata" border=1>
<tr>
<td colspan= 2> my Brief introduction </td>
</tr>
<tr>
<td> My name:</td>
<td><span datafld = "Name" ></span></td>
</tr>
<tr>
<td> site name:</td>
<td> <span datafld= "WebName" ></span></td>
</tr>
<tr>
<td> Web site 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) </webname>
<weburl>http://blog.csdn.net/estyle</weburl>
< /weblist>
<webList>
<webname> favorites Chinese cabbage </webname>
<weburl>http://blog.csdn.net/ Qunluo</weburl>
</webList>
</xData>
</xml>
HTML original code when displayed:
<table datasrc= "#xmldataList" border=1>
<thead>
<tr>
<TD colspan=2> My focus on CSDN blog list </td>
</tr>
<tr>
<TD align= "center" > Name </td>
<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 requirement that browsers must support XML, and there is a question