serverliving.com
serverliving.com

Reputation: 457

How to Concat Parent tag with Child tag name in XSLT

How to Concat Parent tag with Child tag name in XSLT

Currently I am able to get parent and child node values but i don't know how to join them as single value

<xsl:value-of select="name()"/>  //gives child name
<xsl:value-of select="name(..)"/> //gives parent name

I want to do something like <xsl:value-of select="concat(name(..),name())"/>

so result would be Parent_Child

Upvotes: 0

Views: 179

Answers (2)

Vebbie
Vebbie

Reputation: 1695

If you want to create a new element name based on that

<xsl:element name="{concat(name(..),'_',name(.))}"/>

Upvotes: 0

Thomas W
Thomas W

Reputation: 15371

There are multiple options:

  • concat()
  • Multiple value-of, like

    <xsl:value-of select="name()"/>_<xsl:value-of select="name(..)"/>

Upvotes: 1

Related Questions