我想知道是否有一种方法可以使用 XSLT 传递具有相同元素名称的所有子元素的父元素。
例如,如果原始的xml文件是这样的:
<parent>
<child>1</child>
<child>2</child>
<child>3</child>
</parent>
我尝试使用 xsl 解析它:
<xsl:for-each select="parent">
<print><xsl:value-of select="child"></print>
想要这样的东西:
<print>1</print>
<print>2</print>
<print>3</print>
但我明白了:
<print>1</print>
因为 for-each 更适合这种格式:
<parent>
<child>1</child>
<parent>
</parent
<child>2</child>
<parent>
</parent
<child>3</child>
</parent
无论如何都可以获得所需的打印输出而不像上面那样格式化它,而是第一种方式?
谢谢