2010-07-30 32 views
0

我該如何實現對通過php調用的xml數據進行分頁。我一直在嘗試各種jquery分頁的XML文件沒有運氣。分頁xml數據

HTML/PHP代碼讀取XML數據:

<div id="display"> 
     <?php 
     error_reporting(E_ALL); 
     ini_set("display_errors", 1); 

      $xmldoc = new DOMDocument(); 
      if(!file_exists('test.xml')){ 
       echo "Sorry this file does not exists!"; 
       exit(); 
      } else { 
       $xmldoc->load('test.xml', LIBXML_NOBLANKS); 

       // Load up the XSL file 
       $xslDoc = new DomDocument; 
       $xslDoc->load("test.xsl"); 
       $xsl = new XSLTProcessor; 
       $xsl->importStyleSheet($xslDoc); 

       // apply the transformation 
       echo $xsl->transformToXml($xmldoc); 
      } 
     ?> 
    </div> 

腳本[one example]:

<script type="text/javascript" src="jquery-1.4.2.js"></script> 
<script type="text/javascript" src="paginator.js"></script> 
<script type="text/javascript"> 
    $(function(){ $("#display").pagination(); }); 
</script> 

回答

1

你需要決定什麼將是在不同的頁面。這完全取決於xml文件的內容。我認爲你不會找到一個很好的通用解決方案。

+0

單獨頁面在?請詳細說明。你的意思是說分頁腳本必須放在php頁面或xsl上? – input 2010-07-30 18:26:51

+0

不,我的意思是,如果你打算把任何東西分解成單獨的頁面,你需要決定每頁上的內容。如果你的xml數據是一堆地址記錄,你可能需要在一個頁面上使用25。如果你的XML是單篇文章,你需要決定你將要分割的地方。 – 2010-07-30 18:30:19

+0

它是顯示英文文本和翻譯的記錄。我如何使xml文件或分頁顯示每頁10條記錄? – input 2010-07-30 18:45:53