我有一个需求来创建一个类似于下面的xml文件中的动态表格,我可以使用xpath
或类似的内容在其中显示filesystem
内容,具有适当的变量分页,过滤,排序和选择特定的行。如何从xml文件创建动态html表格
<?xml-stylesheet type="text/xsl" href="csmclientiir.xsl"?>
<csmclient product="abc" date="4/26/11 2:05 PM">
<system>
<osname>Linux
</osname>
<hostname>AbhishekNix
</hostname>
<release>2.6.18-128.el5
</release>
<filesystem>
<file mount='/home/hp1' home='(innfs2:/vol/home/shome/home/hp1)' total='1717567488' free='644306780' used='1073260708' percentage='62' />
<file mount='/home/par21' home='(innfs2:/vol/home/shome/home/par21)' total='1717567488' free='644306780' used='1073260708' percentage='62' />
<file mount='/home/h231' home='(innfs2:/vol/home/shome/home/h231)' total='1717567488' free='644306780' used='1073260708' percentage='62' />
<file mount='/home/avallin1' home='(innfs2:/vol/home/shome/home/avallin1)' total='1717567488' free='644306780' used='1073260708' percentage='62' />
<file mount='/home/park' home='(innfs2:/vol/home/shome/home/park)' total='1717567488' free='644306780' used='1073260708' percentage='62' />
<file mount='/home/sp1' home='(innfs2:/vol/home/shome/home/sp1)' total='1717567488' free='644306780' used='1073260708' percentage='62' />
<file mount='/home/ganga1' home='(innfs2:/vol/home/shome/home/ganga1)' total='1717567488' free='644306780' used='1073260708' percentage='62' />
<file mount='/home/nbp1' home='(innfs2:/vol/home/shome/home/nbp1)' total='1717567488' free='644306780' used='1073260708' percentage='62' />
</filesystem>
</system>
<product>
<showtime>Tue Apr 26 14:05:23 2011
</showtime>
</product>
</csmclient>
编辑
这是我使用jqGrid
jQuery("#listTable").jqGrid({
url: cpath,
datatype: "xml",
colNames:["Total Space","Free Space","Used Space", "Used Percentage"],
colModel:[ {name:"Total Space",index:"Total Space", width:90, xmlmap:"system>filesystem>file>@total"},
{name:"Free Space",index:"Free Space", width:120, xmlmap:"system>filesystem>file>@free"},
{name:"Used Space",index:"Used Space", width:180,xmlmap:"system>filesystem>file>@used"},
{name:"Used Percentage",index:"Used Percentage", width:100, align:"right",xmlmap:"system>filesystem>file>@percentage", sorttype:"float"}
],
height:250,
pager: '#pager',
rowNum:10,
rowList:[10,20,30],
viewrecords: true,
gridview: true,
loadonce: true,
xmlReader: {
root : "csmclient",
row: "system>filesystem",
repeatitems: false,
id: "ASIN"
},
caption: "Disk Usage"
});
那只能说明没有任何数据的标题
注意使用:我的XML文件结构是固定的
你有没有想要输出的样本?你有没有尝试过,或者你只是想要一个完整的解决方案? – Ben 2011-06-17 08:58:01
@Ben:我试图用'spry'完美的工作,但我被要求只使用一种技术,所以我使用jquery很多,所以不得不单独使用jQuery,我会编辑我的问题以包含示例 – Ricky 2011-06-17 09:00:55
Doesn 't http://www.datatables.net/做的伎俩? – MiPnamic 2011-06-17 09:16:03