Concatenate several child items into one child ite

2019-09-22 10:33发布

I have an xml with several parent-child structures. One structure is like this:

<parent>
  <child>Sam</child>
  <child>Tom</child>
  <child>Joe</child>
</parent>

I want the result to look like this:

<parent>
  <child>Sam;Tom;Joe</child>
</parent>

How do I achieve the result in XSLT?

标签: xml xslt
1条回答
爷的心禁止访问
2楼-- · 2019-09-22 11:23

In XSLT 2.0 you can write:

<xsl:template match="parent">
  <xsl:copy>
    <child>
      <xsl:value-of select="child" separator=";"/>
    </child>
  </xsl:copy>
</xsl:template>
查看更多
登录 后发表回答