溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

使用XML如何創(chuàng)建可排序、分頁(yè)的數(shù)據(jù)顯示頁(yè)面

發(fā)布時(shí)間:2021-01-27 09:49:50 來源:億速云 閱讀:279 作者:小新 欄目:編程語(yǔ)言

小編給大家分享一下使用XML如何創(chuàng)建可排序、分頁(yè)的數(shù)據(jù)顯示頁(yè)面,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

在Web開發(fā)中,我們經(jīng)常會(huì)遇到分頁(yè)顯示和排序數(shù)據(jù)記錄集的情況,這在服務(wù)器端使用服務(wù)器端的代碼和數(shù)據(jù)庫(kù)技術(shù)是件很輕松的事情,比如:asp、php、jsp等。然而,如果要在客戶端顯示多條記錄并且排序是一件很令人頭疼的事情。下面,我們利用Extensible Markup Language(xml,可擴(kuò)展標(biāo)記語(yǔ)言)和Extensible Stylesheet Language Transformations(XSLT,可擴(kuò)展樣式單語(yǔ)言轉(zhuǎn)換),并結(jié)合XML Path Language(XPath,XML路徑語(yǔ)言),只需要編寫簡(jiǎn)單的代碼,就可輕松實(shí)現(xiàn)。這種方法避免了與服務(wù)器頻繁打交道的過程,節(jié)省了數(shù)據(jù)顯示的時(shí)間,瀏覽者無(wú)須等待就可以看到結(jié)果,也可以減少服務(wù)器的負(fù)擔(dān)。另外。由于XML和XSLT技術(shù),使數(shù)據(jù)存儲(chǔ)和數(shù)據(jù)顯示分離,還可以讓我們的代碼能夠重復(fù)利用,大大減輕了程序員編寫代碼的負(fù)擔(dān)。  
  下面,我們一步一步地來實(shí)現(xiàn)我們的功能。  
   
  首先:創(chuàng)建XSLT  
   
  XSLT樣式單的第一行標(biāo)明該XML所遵照的XML規(guī)范版本,然后是標(biāo)明該樣式單使用的名稱空間,這里,我們以XSL規(guī)范的正式版本來進(jìn)行編寫,而不采用XSL的草案的寫法:

   <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

注意:兩者在功能和寫法上有很大的差異。  

 <?xml version="1.0"?>  
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

接下來,我們定義XSLT里的模板標(biāo)記:  

<xsl:template match="/">  
   <xsl:apply-templates select="/客戶關(guān)系表"/>  
   </xsl:template>  
    
   <xsl:template match="/客戶關(guān)系表"></xsl:template>


  我們把要顯示的樣式寫到模板里面。我們使用HTML的數(shù)據(jù)島來存放我們的數(shù)據(jù),這些數(shù)據(jù)可以利用SQL Server 2000的XML查詢來得到,對(duì)于不支持XML的數(shù)據(jù)庫(kù),我們可以自己編寫組件把數(shù)據(jù)轉(zhuǎn)換成XML格式,然后在放到數(shù)據(jù)島里。在HTML里使用數(shù)據(jù)島有兩種方法:  
  一是直接嵌入數(shù)據(jù),如下所示:

 <XML id=''Data''>  
   <客戶關(guān)系表>  
   <客戶>每條數(shù)據(jù)</客戶>  
   </客戶關(guān)系表>  
   </XML>

二是通過SRC屬性引用外部文件,如下所示:  

 <XML id=''Data'' src=''Data.xml''></XML>

要使用數(shù)據(jù)島里的數(shù)據(jù),必須通過id名來引用它,當(dāng)然,由于XSLT文件也是XML格式文件的一種,也可以通過這種方法來實(shí)現(xiàn):  

<XML id=''Style'' src=''Style.xsl''></XML>

我們?cè)陧?yè)面中加入標(biāo)記DIV來顯示我們的轉(zhuǎn)換的結(jié)果:  

   <div id="DisplayArea"></div>


  使用XSLT轉(zhuǎn)換數(shù)據(jù)島里的數(shù)據(jù),采用DOMDocument的transNode()方法,并把結(jié)果通過DIV的innerHTML屬性來展現(xiàn)出來:  
 

DisplayArea.innerHTML = Data.transformNode(Style.DocumentElement)

第二步:實(shí)現(xiàn)客戶端排序的功能  
   
  我們先設(shè)定一個(gè)默認(rèn)的排序字段,這里選擇“序號(hào)”作為默認(rèn)的排序關(guān)鍵字,并且是按遞增的順序排列,在XSLT里加入sort標(biāo)記:

<xsl:for-each select="客戶">  
   <xsl:sort select="序號(hào)" order="descending" data-type="number"/>  
   </xsl:for-each>

接下來,我們?yōu)闃邮奖碓黾优判虻墓δ?,以便可以響?yīng)用戶的操作,我們?cè)诒眍^的每個(gè)列上添加onClick事件,該事件調(diào)用sort()函數(shù),允許用戶通過單擊該表頭來進(jìn)行對(duì)該列的排序。

  <td onClick="sort(''序號(hào)'')">序號(hào)</td>  
   Sort()函數(shù)的語(yǔ)句如下所示:  
   Function Sort(strField)  
    
   Dim sortField  
   Dim sortOrderAttribute  
    
   '' 得到原來排序字段的屬性值  
   Set sortField = Style.XMLDocument.selectSingleNode("//xsl:sort/@select")  
    
   '' 得到原來排序的順序?qū)傩灾?nbsp; 
   Set sortOrderAttribute = Style.XMLDocument.selectSingleNode("//xsl:sort/@order")  
    
   '' 如果我們已經(jīng)按所點(diǎn)擊的列的字段排序,我們必須改變排序的順序;  
   '' 否則,我們只需要按新所點(diǎn)擊的列字段按默認(rèn)的順序進(jìn)行排序  
   If sortField.Value = strField Or sortField.Value = "./*[0]" Then  
   If sortOrderAttribute.Value = "descending" Then  
   sortOrderAttribute.Value = "ascending"  
   Else  
   sortOrderAttribute.Value = "descending"  
   End If  
   Else  
   sortField.Value = strField  
   sortOrderAttribute.Value = "ascending"  
   End If  
    
   Set sortField = Nothing  
   Set sortOrderAttribute = Nothing  
   '' 輸出排序后的結(jié)果  
   DisplayArea.innerHTML = Data.transformNode(Style.DocumentElement)  
    
   End Function

下面,我們實(shí)現(xiàn)每頁(yè)面顯示的記錄數(shù)和設(shè)定前頁(yè)、后頁(yè)的功能。使用span標(biāo)記顯示目前顯示的是第幾頁(yè)、共多少頁(yè)和記錄的總數(shù)。我們默認(rèn)每頁(yè)顯示6條記錄,用變量intRecordsPerPage保存該值:

<table width="100%" border="0" style="font-size:9pt">  
   <tr>  
   <td align="left"><b>第 <span id="CurrentPage"></span> 頁(yè) 總 <span id="PageCount"></span> 頁(yè)    共有 <span id="RecordCount"></span> 條記錄</b></td>  
   <td align="right"><b>每頁(yè)記錄數(shù):<input onblur="setRecordsPerPage()" id="RecordsPerPage" style="vertical-align:middle;height:15pt;width:30px"/></b></td>  
   <td align="right">  
   <span id="Paging">  
   <input type="button" OnClick="FirstPage()" value="第一頁(yè)"/>  
   <input type="button" OnClick="PReviousPage(1)" value="上一頁(yè)"/>  
   <input type="button" OnClick="nextPage(1)" value="下一頁(yè)"/>  
   <input type="button" OnClick="LastPage()" value="最末頁(yè)"/>  
   </span>  
   </td>  
   </tr>  
   </table>

下面以“下一頁(yè)”按鈕執(zhí)行的操作為例子,說明轉(zhuǎn)換不同頁(yè)面的處理過程。該函數(shù)根據(jù)參數(shù)intPage來決定要顯示的記錄的條數(shù)和相應(yīng)的頁(yè)面,每個(gè)按鈕Value值的變化是通過動(dòng)態(tài)改變XSL DOM的內(nèi)容來實(shí)現(xiàn)的:

Function nextPage(intPage)  
    
   Dim strDisplay  
   Dim strDateRange  
    
   If CInt(CStr(intPage) * intRecordsPerPage) < _  
   Data.selectNodes("/客戶關(guān)系表/客戶").length Then  
   intPage = CInt(intPage) + 1  
    
   Style.XMLDocument.selectNodes("//@OnClick") _  
   (1).Value = "previousPage(" & intPage & ")"  
    
   Style.XMLDocument.selectNodes("//@OnClick") _  
   (2).Value = "nextPage(" & intPage & ")"  
    
   Style.XMLDocument.selectNodes _  
   ("//xsl:for-each/@select")(1).Value = _  
   "./客戶[position() <= " & (CStr(intPage) _  
   * intRecordsPerPage) & " and position() > " _  
   & (CInt(intPage) - 1) * intRecordsPerPage & _  
   "]"  
    
   redisplay (intPage)  
    
   End If  
    
   End Function

下面,我們來看看設(shè)置每個(gè)頁(yè)面記錄條數(shù)的函數(shù)setRecordsPerPage(),該函數(shù)通過動(dòng)態(tài)修改xsl:for-each的select屬性值來實(shí)現(xiàn)的,使用XPath來遍歷那些符合節(jié)點(diǎn)位置大于0并且節(jié)點(diǎn)位置小于每頁(yè)記錄數(shù)加1的那些節(jié)點(diǎn)。其中主要的語(yǔ)句是下面的一行:  
  Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1). _  
  value = "./客戶[position() < " & intRecordsPerPage + 1 & " and "& " position() > 0]"  
  到目前為止,我們的頁(yè)面既可以實(shí)現(xiàn)排序,也實(shí)現(xiàn)動(dòng)態(tài)改變每頁(yè)顯示記錄條數(shù)的功能了,為了實(shí)現(xiàn)可重用的要求,我們還可以進(jìn)行進(jìn)一步的改進(jìn)。XPath是進(jìn)行XML/XSLT應(yīng)用開發(fā)的一個(gè)強(qiáng)有力的工具,XPath中可以使用通配符,使XSLT樣式單文件完全不依賴于你的數(shù)據(jù)節(jié)點(diǎn)名稱。因此,我們?cè)诟淖僗ML數(shù)據(jù)的時(shí)候,只要不改變節(jié)點(diǎn)的層次關(guān)系,可以不必改動(dòng)XSLT就可以直接使用。比如:在本例中,你可以添加或者刪除某些字段、或添加刪除一些記錄,直接使用本例中的XSLT,不但可以在表格里正常顯示出數(shù)據(jù),而且還能正常排序和分頁(yè)。  
  下面我們就分析一下是如何實(shí)現(xiàn)的。比如下面的層次關(guān)系:

 <客戶關(guān)系表>  
   <客戶>  
   <序號(hào)></序號(hào)>  
   <姓名></姓名>  
   <電子郵件></電子郵件>  
   </客戶>  
   </客戶關(guān)系表>

假如我們的XSLT中有這樣一個(gè)選擇模板的句子:

<xsl:apply-templates select="/客戶關(guān)系表"/>

為了實(shí)現(xiàn)通用性的要求,我們可以使用通配符:

  <xsl:apply-templates select="/*"/>

這里我們使用了子運(yùn)算符"/",它選擇了根下的所有節(jié)點(diǎn),兩者的不同點(diǎn)在于:"/客戶關(guān)系表"選擇的是根下的客戶關(guān)系表子節(jié)點(diǎn),而"/*"選擇的是根下所有的直接子節(jié)點(diǎn),在上面的XML數(shù)據(jù)格式中,二者是完全等價(jià)的。  
  對(duì)于下面的for-each循環(huán)來說:

<xsl:for-each select="客戶">  
   <xsl:sort select="序號(hào)" order="ascending"/>  
   </xsl:for-each>

我們可以改變成這樣的形式:

  <xsl:for-each select="./*">  
   <xsl:sort select="./*[1]" order="ascending"/>  
   </xsl:for-each>

這里"./*"表示你應(yīng)當(dāng)包含進(jìn)去當(dāng)前節(jié)點(diǎn)下所有的一級(jí)子節(jié)點(diǎn),語(yǔ)法"./*[1]"表示的是選擇當(dāng)前節(jié)點(diǎn)中的第一個(gè)子節(jié)點(diǎn)。  
  另外還有一個(gè)地方可以改進(jìn)的是<xsl:value-of select="序號(hào)"/>,我們可以把它改成<xsl:value-of select="."/>,表示在每一次循環(huán)中選擇當(dāng)前節(jié)點(diǎn)。  
  在我們的函數(shù)中,還使用了一些硬代碼,如果不做改動(dòng)的話,我們的通用性還是實(shí)現(xiàn)不了,因此,我們下面就看看如何替換硬代碼中的語(yǔ)句。  
  在創(chuàng)建表頭的時(shí)候,我們使用了<td onClick="sort(''序號(hào)'')"> 序號(hào)</td>的語(yǔ)句,如果XML數(shù)據(jù)里沒有序號(hào)節(jié)點(diǎn)的話,這里顯然會(huì)出現(xiàn)錯(cuò)誤的,為了實(shí)現(xiàn)通用性,我們自定義了一個(gè)函數(shù)getName,來取得所要顯示的節(jié)點(diǎn)的名稱:

<td>  
   <xsl:attribute name="onClick">  
   Sort(''<xsl:value-of select="user:getName(.)"/>'')  
   </xsl:attribute>  
   <xsl:value-of select="user:getName(.)"/>  
   </td>

自定義函數(shù)是XSLT的一個(gè)突出的功能,要使用這個(gè)特性,我們得用msxml:script元素來定義,同時(shí),必須在樣式單定義的時(shí)候指定一個(gè)用戶定義的名字空間。下面就是我們使用自定義函數(shù)的全部?jī)?nèi)容:

 <xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform  
   xmlns:msxsl="urn:schemas-microsoft-com:xslt"  
   xmlns:user="http://lucky.myrice.com"  
   version="1.0">  
   <msxsl:script language="VBScript" implements-prefix="user">  
   <![CDATA[  
   function getName(node)  
   getName = node.item(0).nodeName  
   end function  
   }>  
   </msxsl:script>

在我們的XSLT文件中,使用了兩個(gè)循環(huán),我們分別進(jìn)行相應(yīng)的更改,第一處:顯示表頭的地方改為<xsl:for-each select="./*[1]/*">,它等同于<xsl:for-each select="客戶關(guān)系表/客戶[1]/*">;第二處循環(huán)是顯示每行記錄,改成<xsl:for-each select="./*">。還有其他的地方需要更改的,請(qǐng)參見后面的完整源代碼部分。這樣我們就完成了通用的XSLT文件,不管你的XML數(shù)據(jù)有多少字段,也不管節(jié)點(diǎn)名稱是什么,我們都無(wú)需更改XSLT文件,就可以實(shí)現(xiàn)我們的功能了。最終的瀏覽效果將會(huì)象下圖所示:

使用XML如何創(chuàng)建可排序、分頁(yè)的數(shù)據(jù)顯示頁(yè)面

以下是完整的Style.xsl文件的內(nèi)容:

<?xml version="1.0" encoding="gb2312"?>  
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="http://lucky.myrice.com" version="1.0">  
   <msxsl:script language="VBScript" implements-prefix="user">  
   <![CDATA[  
   Function getName(node)  
   getName = node.Item(0).nodeName  
   End Function  
   }>  
   </msxsl:script>  
    
   <xsl:template match="/">  
   <xsl:apply-templates select="/*"/>  
   </xsl:template>  
    
   <xsl:template match="/*">  
   <table width="100%" border="0" style="font-size:9pt">  
   <tr>  
   <td align="left"><b>第 <span id="CurrentPage"></span> 頁(yè) 總 <span id="PageCount"></span> 頁(yè)    共有 <span id="RecordCount"></span> 條記錄</b></td>  
   <td align="right"><b>每頁(yè)記錄數(shù):<input onblur="setRecordsPerPage()" id="RecordsPerPage" style="vertical-align:middle;height:15pt;width:30px"/></b></td>  
   <td align="right">  
   <span id="Paging">  
   <input type="button" OnClick="FirstPage()" value="第一頁(yè)"/>  
   <input type="button" OnClick="previousPage(1)" value="上一頁(yè)"/>  
   <input type="button" OnClick="nextPage(1)" value="下一頁(yè)"/>  
   <input type="button" OnClick="LastPage()" value="最末頁(yè)"/>  
   </span>  
   </td>  
   </tr>  
   </table>  
   <Table WIDTH="100%" BORDER="0" cellpadding="0" cellspacing="1" style="font-size:11pt" bgcolor="#0099ff">  
   <tr bgcolor="#FF6600" style="cursor: hand;padding:5px">  
   <xsl:for-each select="./*[1]/*">  
   <td align="center">  
   <xsl:attribute name="onclick">  
   Sort(''<xsl:value-of select="user:getName(.)"/>'')  
   </xsl:attribute>  
   <font color="#EEEEEE"><b><u><xsl:value-of select="user:getName(.)"/></u></b></font>  
   </td>  
   </xsl:for-each>  
   </tr>  
   <xsl:for-each select="./*[position() < 6 and position() > 0]">  
   <xsl:sort select="./*[1]" order="ascending"/>  
   <tr bgcolor="#FFCCFF">  
   <xsl:for-each select="./*">  
   <td> <xsl:value-of select="."/></td>  
   </xsl:for-each>  
   </tr>  
   </xsl:for-each>  
   </Table>  
   </xsl:template>  
   </xsl:stylesheet>  
   以下是進(jìn)行輸出的Exam.htm文件:  
   <HTML>  
   <Head>  
   <META http=equiv="Content-Type" Content="text/html;charset=gb2312">  
   <STYLE>  
   body { font-family:宋體; font-size:9pt;}  
   th { font-family:宋體; font-size:11pt; font-weight:bold;}  
   </STYLE>  
   <Script language="vbscript">  
   Option Explicit  
    
   Dim intRecordsPerPage ''每個(gè)頁(yè)面顯示的記錄數(shù)  
   intRecordsPerPage = 6 ''每個(gè)頁(yè)面顯示的記錄數(shù),默認(rèn)設(shè)定為6  
    
   '' 更新顯示頁(yè)面的函數(shù)  
   Function window_onload()  
    
   '' 顯示設(shè)定的記錄數(shù)  
   Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() < " & intRecordsPerPage + 1 & " and position() > 0]"  
   transform()  
   setPageCount()  
    
   End Function  
    
   '' 進(jìn)行XML-XSLT轉(zhuǎn)換,并顯示當(dāng)前記錄的一些信息  
   Function transform()  
    
   DisplayArea.innerHTML = Data.transformNode(Style.DocumentElement)  
   RecordsPerPage.Value = intRecordsPerPage  
    
   End Function  
    
   '' 重新轉(zhuǎn)換XML,并顯示一個(gè)狀態(tài)信息  
   Function redisplay(intPage)  
    
   Dim strDisplay  
   Dim intPageCount  
   Dim intRecordCount  
    
   '' 保存狀態(tài)信息  
   intPageCount = PageCount.innerHTML  
   intRecordCount = RecordCount.innerHTML  
   transform()  
   '' 顯示狀態(tài)信息  
   PageCount.innerHTML = intPageCount  
   RecordCount.innerHTML = intRecordCount  
   CurrentPage.innerHTML = intPage  
    
   End Function  
    
   '' 重新排序和顯示  
   Function Sort(strField)  
    
   Dim sortField  
   Dim sortOrderAttribute  
   '' 得到排序?qū)傩灾?nbsp; 
   Set sortField = Style.XMLDocument.selectSingleNode("//xsl:sort/@select")  
   Set sortOrderAttribute = Style.XMLDocument.selectSingleNode("//xsl:sort/@order")  
    
   '' 改變排序的方式  
   If sortField.Value = strField Or sortField.Value = "./*[0]" Then  
   If sortOrderAttribute.Value = "descending" Then  
   sortOrderAttribute.Value = "ascending"  
   Else  
   sortOrderAttribute.Value = "descending"  
   End If  
   Else  
   sortField.Value = strField  
   sortOrderAttribute.Value = "ascending"  
   End If  
    
   Set sortField = Nothing  
   Set sortOrderAttribute = Nothing  
    
   redisplay (CurrentPage.innerHTML)  
    
   End Function  
    
   '' 重新設(shè)置每頁(yè)的記錄數(shù)  
   Function setRecordsPerPage()  
    
   If IsNumeric(RecordsPerPage.Value) Then  
   intRecordsPerPage = CInt(RecordsPerPage.Value)  
   window_onload  
   End If  
    
   End Function  
    
   '' 顯示頁(yè)數(shù)信息  
   Function setPageCount()  
    
   Dim intTotalRecords  
    
   PageCount.innerHTML = getNumberOfPages(intTotalRecords)  
   RecordCount.innerHTML = intTotalRecords  
   CurrentPage.innerHTML = 1  
    
   End Function  
    
   '' 計(jì)算總頁(yè)數(shù)和總記錄數(shù)  
   Function getNumberOfPages(intTotalRecords)  
    
   Dim intPages  
    
   intTotalRecords = Data.XMLDocument.selectNodes("/*/*").length  
   intPages = intTotalRecords / intRecordsPerPage  
   If InStr(intPages, ".") > 0 Then  
   intPages = CInt(Left(intPages, InStr(intPages, "."))) + 1  
   End If  
    
   getNumberOfPages = intPages  
    
   End Function  
    
   '' “下一頁(yè)”的處理  
   Function nextPage(intPage)  
    
   Dim strDisplay  
   Dim strDateRange  
    
   If CInt(CStr(intPage) * intRecordsPerPage) < Data.selectNodes("/*/*").length Then  
   intPage = CInt(intPage) + 1  
   Style.XMLDocument.selectNodes("//@OnClick")(1).Value = "previousPage(" & intPage & ")"  
   Style.XMLDocument.selectNodes("//@OnClick")(2).Value = "nextPage(" & intPage & ")"  
   Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() <= " & (CStr(intPage) * intRecordsPerPage) & " and position() > " & (CInt(intPage) - 1) * intRecordsPerPage & "]"  
   redisplay (intPage)  
   End If  
    
   End Function  
    
   '' 處理“上一頁(yè)”  
   Function previousPage(intPage)  
    
   Dim strDisplay  
   Dim strDateRange  
    
   If intPage > 1 Then  
   intPage = CInt(intPage) - 1  
   Style.XMLDocument.selectNodes("//@OnClick")(1).Value = "previousPage(" & intPage & ")"  
   Style.XMLDocument.selectNodes("//@OnClick")(2).Value = "nextPage(" & intPage & ")"  
   Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() <= " & (CStr(intPage) * intRecordsPerPage) & " and position() > " & (CInt(intPage) - 1) * intRecordsPerPage & "]"  
   redisplay (intPage)  
   End If  
    
   End Function  
    
   '' “第一頁(yè)”的處理  
   Function FirstPage()  
    
   Style.XMLDocument.selectNodes("//@OnClick")(1).Value = "previousPage(1)"  
   Style.XMLDocument.selectNodes("//@OnClick")(2).Value = "nextPage(1)"  
   Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() < " & intRecordsPerPage + 1 & " and position() > 0]"  
   transform()  
   setPageCount()  
    
   End Function  
    
   '' “最末頁(yè)”的處理  
   Function LastPage()  
    
   Dim intTotalPages  
   Dim intTotalRecords  
    
   intTotalPages = getNumberOfPages(intTotalRecords)  
   nextPage (intTotalPages - 1)  
    
   End Function  
   </Script>  
   </Head>  
   <body>  
   <p align="center" style="font-weight:bold;font-size:12pt;color:#0000FF;border-bottom:3px double red;padding-bottom:5px">客戶關(guān)系表</p>  
   <XML id=''Data''>  
   <客戶關(guān)系表 xmlns:dt="urn:schemas-microsoft-com:datatypes">  
   <客戶><序號(hào) dt:dt="int">01</序號(hào)><姓名>Mi</姓名><電子郵件>water@21cn.com</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">02</序號(hào)><姓名>uyi</姓名><電子郵件>Lily@sina.com</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">03</序號(hào)><姓名>uiyu</姓名><電子郵件>John@21cn.com</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">04</序號(hào)><姓名>Doug</姓名><電子郵件>Karry@163.net</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">05</序號(hào)><姓名>Ellen</姓名><電子郵件>vivki@sina.com</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">06</序號(hào)><姓名>Frank</姓名><電子郵件>net_lover@mengxianhui.com.cn</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">07</序號(hào)><姓名>Greg</姓名><電子郵件>meng@mengxianhui.com</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">08</序號(hào)><姓名>Harry</姓名><電子郵件>sunny@xianhui.net</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">09</序號(hào)><姓名>Ingrid</姓名><電子郵件>cathy@hotmail.com</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">10</序號(hào)><姓名>Jeff</姓名><電子郵件>your@mxh.com</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">11</序號(hào)><姓名>Kelly</姓名><電子郵件>Iloveyou@mengxianhui.com</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">12</序號(hào)><姓名>Larry</姓名><電子郵件>smilling@mengxianhui.com</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">13</序號(hào)><姓名>Mark</姓名><電子郵件>money@21cn.com</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">14</序號(hào)><姓名>Nancy</姓名><電子郵件>www@yahoo.com</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">15</序號(hào)><姓名>Peter</姓名><電子郵件>dotnet@aol.com</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">16</序號(hào)><姓名>Rachel</姓名><電子郵件>billgates@microsoft.com</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">17</序號(hào)><姓名>Seth</姓名><電子郵件>flying@yous.net</電子郵件></客戶>  
   <客戶><序號(hào) dt:dt="int">18</序號(hào)><姓名>Tim</姓名><電子郵件>agooyboy@lovegirl.com</電子郵件></客戶>  
   </客戶關(guān)系表>  
   </XML>  
   <XML id=''Style'' src=''Style.xsl''></XML>  
   <div id="DisplayArea"></div>  
   <table border="0" width="100%" style="font-size:11pt;">  
   <tr>  
   <td align="right">資料來源:【<a href="http://lucky.myrice.com">孟憲會(huì)之精彩世界</a>】</td>  
   </tr>  
   </table>  
   </body>  
   </HTML>

把上面的內(nèi)容拷貝到本地計(jì)算機(jī)上,分別保存為相應(yīng)的文件,在IE5+和XML3.0+的環(huán)境下即可看到效果!

以上是“使用XML如何創(chuàng)建可排序、分頁(yè)的數(shù)據(jù)顯示頁(yè)面”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

xml
AI