我刚刚学习了xpath和xsl,我有一个问题。
我如何将注释添加<!-- foo -->到名为 foo 的每个 xml 元素的开头?
我可以使用 xpath 或 xslt 来完成吗?
是的,有一个 XSLT 元素:<xsl:comment>。
为了执行您所描述的操作,您可以使用以下命令:
<!-- Match foo elements in the XML -->
<xsl:template match="foo">
<xsl:comment>foo</xsl:comment>
<foo>
<xsl:apply-templates />
</foo>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3330 次 |
| 最近记录: |