Hi,
I am a novice in XSLT. Just started reading about it today and came across few of the tags.

Can you help in creating the XSLT for the following transformation..

<A>
  <B>
    <C> Hello </C>
  <B>
  <B>
  </B>
</A>

I need to convert this into:

<A>
  <B>
    <C> Hello </C>
  <B>
  <B>
    [B]<C> </C>[/B] //this should be added in new XML
  </B>
</A>

Using your input.

<A>
  <B>
    <C> Hello </C>
  </B>
  <B>
  </B>
</A>

XSLT

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" indent="yes"/>
	<xsl:strip-space elements="*"/>

	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*"/>
			<xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="B[not(C)]">
		<xsl:copy>
			<C/>
		</xsl:copy>
	</xsl:template>

</xsl:stylesheet>

RESULT

<A>
	<B>
		<C>Hello</C>
	</B>
	<B>
		<C/>
	</B>
</A>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.