获取节点总数和计数节点

发布于 2024-07-27 01:17:07 字数 58 浏览 2 评论 0原文

是否可以获得 XML 节点的总数?

另外,如何使用 XSLT 执行 for 语句?

Is it possible to get the total number of XML nodes?

Also, how does one do a for-statement with XSLT?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

染墨丶若流云 2024-08-03 01:17:07

如果你想计算 XML 的节点数,你可以使用 count(object/node) ,它会是这样的:

 <xsl:value-of select="count(/root/*)"/>

上面的指令将让你知道你的根节点有多少个子节点

<xsl:for-each select="/root/element-you-wanna-loop" >
    <!-- Do something with your nodes here -->    
</xsl:for-each>

希望这对你有帮助。

If you want to count the node of you XML you could use count(object/node) and it will be something like this:

 <xsl:value-of select="count(/root/*)"/>

The instruction above will let you know how many child nodes does your root node has

<xsl:for-each select="/root/element-you-wanna-loop" >
    <!-- Do something with your nodes here -->    
</xsl:for-each>

Hope this helps you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文