xslt解析xml文件 谁个帮忙
projects.xml
<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="projects.xsl"?><projects> <project> <Name>Project 1</Name> </project> <project> <Name>Project 2</Name> </project> <project> <Name>Project 3</Name> </project> <project> <Name>Project 4</Name> </project> <project> <Name>Project 5</Name> </project> <project> <Name>Project 6</Name> </project> <project> <Name>Project 7</Name> </project> <project> <Name>Project 8</Name> </project> <project> <Name>Project 9</Name> </project></projects>
<div class="panel"> <xsl:for-each select="projects/project[position()<5]"> <div class="tab2" id="tab{position()}"> <p class="tab_content_top"><xsl:value-of select="Name"/></p> <p class="tab_content"><xsl:number value="position()" format="1"/></p> <a href="http://www.865171.cn" class="read_more"><img src="../resource/html_template/images/read_more.gif" alt="" title="" border="0" /></a> </div> </xsl:for-each> </div> <div class="panel"> <xsl:for-each select="projects/project[position() > 4]"> <xsl:choose> <xsl:when test="position()+4 > 8"> </xsl:when> <xsl:otherwise> <div class="tab2" id="tab{position()+4}"> <p class="tab_content_top"><xsl:value-of select="Name"/></p> <p class="tab_content"><xsl:number value="position()+4" format="1"/></p> <a href="http://www.865171.cn" class="read_more"><img src="../resource/html_template/images/read_more.gif" alt="" title="" border="0" /></a> </div> </xsl:otherwise> </xsl:choose> </xsl:for-each> </div>
<xsl:for-each select="project[position() > 0 and position() < 9]"> <div><span><xsl:number value="position()" format="1"/></span><span><xsl:value-of select="Name"/></span></div> <xsl:if test="position() div $group"><p/></xsl:if></xsl:for-each>
[解决办法]
可参考这个
http://dotnet.aspx.cc/article/00000000-0000-0000-0000-000000000004/read.aspx
[解决办法]
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:output method="html"/> <xsl:template match="/"> <div class="panel"> <xsl:for-each select="projects/project[position()<9]"> <div class="tab2" id="tab{position()}"> <p class="tab_content_top"> <xsl:value-of select="Name"/> </p> <p class="tab_content"> <xsl:number value="position()" format="1"/> </p> <a href="http://www.865171.cn" class="read_more"> <img src="../resource/html_template/images/read_more.gif" alt="" title="" border="0"/> </a> </div> <xsl:if test="position()=4"> <xsl:text disable-output-escaping="yes"> </div><div class="panel"> </xsl:text> </xsl:if> </xsl:for-each> <xsl:for-each select="count(projects/project) to 7"> <div class="tab2"/> </xsl:for-each> </div> </xsl:template></xsl:stylesheet>