Tutorials to .com

Tutorials to .com » Asp » Xml » XML and ASP combined with the realization of a simple HTML template function

XML and ASP combined with the realization of a simple HTML template function

Print View , by: iSee ,Total views: 7 ,Word Count: 975 ,Date: Wed, 22 Apr 2009 Time: 9:48 AM

This article is the use of xml data binding feature of the DSO to the realization of asp code and HTML code separation, in order to achieve the rapid replacement of the functions of HTML templates, because I only just came into contact with XML, many are not very familiar with here is only to the idea that, if there are mistakes in this article please refer to the local multi.

Rapid replacement of the current template is basically in the replace function to replace special tags in the template after the show, so a lot of ASP increased the processing time, and the template file is too long, then loaded into memory for processing as well as server memory a test. and to provide a kind of xml data binding features DSO. can replace the operator logo delivered to the client. In order to simplify the HTML template as a result of the production requirements. Therefore, as far as possible to simplify HTML template xml technology it is necessary to of.

To put it simply this way datasrc and only use HTML tags dataFLd these two attributes to achieve. Nonsense not to say, all examples of words. The following two examples will speak for themselves.

Example: a single data
The following is the ASP generated XML data island.
<xml id="xmldata">
<xData>
<name> coder </ name>
Brisk <webname> pearl free </ webname>
<weburl> http://blog.csdn.net/oyiboy </ weburl>
</ xData>
</ xml>

Shows that at the time of the original HTML Code:
<table datasrc="#xmldata" border=1>
<tr>
<td colspan=2> I briefly </ 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: a number of data
The following is the ASP generated XML data island.
<xml id="xmldataList">
<xData>
<webList>
Brisk <webname> pearl free </ webname>
<weburl> http://blog.csdn.net/oyiboy </ weburl>
</ webList>
<webList>
<webname> Estyle ()of fantasy </ webname>
<weburl> http://blog.csdn.net/estyle </ weburl>
</ webList>
<webList>
Favorites <webname> cabbage </ webname>
<weburl> http://blog.csdn.net/qunluo </ weburl>
</ webList>
</ xData>
</ xml>

Shows that at the time of the original HTML Code:
<table datasrc="#xmldataList" border=1>
<thead>
<tr>
<td colspan=2> I am concerned about the 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, we can copy a document to view the actual operating results.)
Second, pay attention to cases of HTML code in the original thead and tbody, show a number of records will be useful, if they do not understand what can be used to remove them to see what would happen after.

Incidentally, the button image and hyperlink data binding and the binding is more or less, such as: <img dataFLd="webimg"> and <button dataFLd="buttonvalue"> </ button>

Limitations that require browser must support XML, there is a doubt. As in cases of a <a dataFLd="weburl"> <span dataFLd="weburl"> </ span> </ a> will show come to <a href = "http://blog.csdn.net/oyiboy"> http://blog.csdn.net/oyiboy </ a> the effect, if not modified in the case of XML data to achieve <a href = " http://blog.csdn.net/oyiboy/?loginname=code "> http://blog.csdn.net/oyiboy </ a> how to make the effect. expert advice please click.




Asp and XML related Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.