且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 for-each xslt 语句中选择父节点的每个子节点?

更新时间:2023-02-09 09:07:49

是的,您可以嵌套 for-each 循环.

Yes, you can nest for-each loops.

试试这个

<xsl:for-each select="Tables/routeAdviceTable/routeAdviceRows/adviceRow">
  <xsl:for-each select="./*">
    <!-- 
      Your code i.e.
      <td class="{name(.)}">
        <xsl:value-of select="."></xsl:value-of>
      </td>
    -->
  </xsl:for-each>
</xsl:for-each>

xpath."指的是当前节点(又名上下文节点"),/*"选择上下文节点的所有子节点.

The xpath "." refers to the current node (a.k.a the "context node"), "/*" select all the child nodes of the context node.