views:

16

answers:

1

how do i implement paging on xml data which is being called through php. i've been trying various jquery pagination on the xml file with no luck.

html/php code reading the xml data:

<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>

script [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  A: 

You need to decide what's going to be on separate pages. That's entirely dependent on the content of the xml file. I don't think you'll find a great general solution.

Scott Saunders
separate pages as in? please elaborate. do you mean to say that the pagination script has to be either put on the php page or the xsl?
fuz3d
No. I mean that if you're going to break anything into separate pages, you need to decide what goes on each page. If your xml data is a bunch of address records, you might want 25 on a page. If your xml is a single article, you need to decide where you're going to split it.
Scott Saunders
it's records displaying english text and it's translation. how do i make the xml file or the paging show 10 records per page?
fuz3d
ahh, i get now what you mean. thanks for the pointer, anyway.
fuz3d