您的位置:程序门 -> web 开发 -> xml/soap



如何用xsl显示这个xml树状菜单


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


如何用xsl显示这个xml树状菜单[已结贴,结贴人:blueatchina]
发表于:2007-02-09 11:10:12 楼主
xml节点格式如下:
<node>
    <id> 00001 </id>
    <text> xxx </text>
    <parentid> </parentid>
</node>
<node>
    <id> 00002 </id>
    <text> xxx </text>
    <parentid> </parentid>
</node>
<node>
    <id> 00003 </id>
    <text> xxx </text>
    <parentid> 00001 </parentid>
</node>
<node>
    <id> 00004 </id>
    <text> xxx </text>
    <parentid> 00001 </parentid>
</node>
<node>
    <id> 00005 </id>
    <text> xxx </text>
    <parentid> 00004 </parentid>
</node>
即是在xml中每个树节点是并列放的,层次关系通过parentid来表示
现在要用xsl显示出节点的树状结构,树的层次是不确定的
发表于:2007-02-09 11:29:181楼 得分:20
<xsl:template   name= "getitems ">
<xsl:param   name= "spstr "> </xsl:param>
<xsl:param   name= "rootid "> </xsl:param>
<xsl:for-each   select= "/nodes/node[parentid=$rootid] ">
<xsl:value-of   select= "$spstr "/> <xsl:value-of   select= "id "/>   -   <xsl:value-of   select= "text "/> <br/>
<xsl:call-template   name= "getitems ">
<xsl:with-param   name= "spstr "> <xsl:value-of   select= "$spstr "/> &#160;&#160; </xsl:with-param>
<xsl:with-param   name= "rootid "   select= "id "> </xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template   match= "/ ">
<xsl:call-template   name= "getitems "> </xsl:call-template>
</xsl:template>
发表于:2007-02-09 17:21:412楼 得分:0
thank   u!   gei   fen
发表于:2007-06-04 15:43:003楼 得分:0
mark


快速检索

最新资讯
热门点击