The value i am getting in a tag is like

<text>customers/id/name/place</text>

now i want to retrieve the last value after the / that is 'place'.The problem i am facing is the value in text is changing for e.g it could be
<text>customers/id/name/place</text>

<text>suppliers/id/Germany/thing</text>

<text>supply/id/location/book</text>


what i want is the last value after the /.Because the value coming in text field is dynamic and i only have to extract the last value after the /.

please help
Thanks

for testing xml

<?xml version="1.0"?>
<root>
	<item>dd/aa/bb/cc</item>
	<item>dd/aa/bb/ss</item>
	<item>dd/aa/bb/qq</item>
	<item>dd/aa/bb/ww</item>
	<item>dd/aa/bb/piozza</item>
	<text>gg/rr</text>
	<text>qwqw/rer/we</text>
	<attribut text="wert/das/bild"/>
</root>

xsl rekursiv template

<text>suppliers/id/Germany/thing</text>
1.suppliers/id/Germany/thing
2.id/Germany/thing
3.Germany/thing
4.thing

4.times ist calling template cut
iteration stop when no slash is in the $cut string

the template cut is inpented of the tag and attribut

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output indent="yes" method="xml"/>
	<xsl:template match="/">
		<result>
			<xsl:apply-templates select="root"/>
		</result>
	</xsl:template>


	<xsl:template match="root">
		<xsl:apply-templates select="text"/>
		<xsl:apply-templates select="item"/>
		<xsl:apply-templates select="attribut/@text"/>
	</xsl:template>

	<xsl:template match="item">
		<xsl:call-template name="cut">
			<xsl:with-param name="cut" select="."/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="text">
		<xsl:call-template name="cut">
			<xsl:with-param name="cut" select="."/>
		</xsl:call-template>
	</xsl:template>

	<xsl:template name="cut">
		<xsl:param name="cut"/>
		<xsl:choose>
			<xsl:when test="contains($cut,'/')">
				<xsl:call-template name="cut">
					<xsl:with-param name="cut" select="substring-after($cut,'/')"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<found>
					<xsl:value-of disable-output-escaping="yes" select="concat('in this tag found ',local-name(.),' the last word &gt;',$cut,'&lt;')"/>
				</found>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="@text">
		<xsl:call-template name="cut">
			<xsl:with-param name="cut" select="."/>
		</xsl:call-template>
	</xsl:template>
</xsl:stylesheet>

result

<?xml version='1.0' ?>
<result>
  <found>in this tag found text the last word >rr<</found>
  <found>in this tag found text the last word >we<</found>
  <found>in this tag found item the last word >cc<</found>
  <found>in this tag found item the last word >ss<</found>
  <found>in this tag found item the last word >qq<</found>
  <found>in this tag found item the last word >ww<</found>
  <found>in this tag found item the last word >piozza<</found>
  <found>in this tag found text the last word >bild<</found>
</result>
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.