XSL手动选择子节点
这里是个愚蠢的问题。今天脑子完全锁住了。
我想从 xml 中手动选择特定的子节点。 例如。
<somenode>
<somechild>Something</somechild>
<somechild>Something else</somechild>
<somechild>Something new</somechild>
<somechild>Something old</somechild>
<somechild>Something borrowed</somechild>
<somechild>Something green ha ha</somechild>
</somenode>
我知道我可以用来
<xsl:for-each select=
选择所有这些。 但是,例如,我如何才能使用 xsl 1.0 选择节点 2?
我知道这是一个非常基本的问题,我应该知道答案。只是度过了糟糕的一天。
Stupid question here. Got total brain-lock today.
I want to manually select a specific child node from xml.
EG.
<somenode>
<somechild>Something</somechild>
<somechild>Something else</somechild>
<somechild>Something new</somechild>
<somechild>Something old</somechild>
<somechild>Something borrowed</somechild>
<somechild>Something green ha ha</somechild>
</somenode>
I know I can use
<xsl:for-each select=
to select all of them.
But how, for example, can I just select node 2 using xsl 1.0 please?
I know its a pretty basic question, and I should know the answer. Just having a bad day.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该做你想要的:
This should do what you want:
http://www.w3.org/TR/xpath/#NT-PredicateExpr
因此,对于您的示例
/somenode/somechild[2]
http://www.w3.org/TR/xpath/#NT-PredicateExpr
So, for your example
/somenode/somechild[2]