i need xslt change value of enabled false if name xyz in below xml file.
my xml file is:
<myroot> <category> <name>xyz</name> <location>mylocation</location> <enabled>true</enabled> </category> <category> <name>abc</name> <location>mylocation1</location> <enabled>true</enabled> </category> <category> <name>def</name> <location>mylocation2</location> <enabled>true</enabled> </category> </myroot>
this how handle it:
xslt
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="category[name='abc']/enabled"> <enabled>false</enabled> </xsl:template> </xsl:stylesheet> output
<myroot> <category> <name>xyz</name> <location>mylocation</location> <enabled>false</enabled> </category> <category> <name>abc</name> <location>mylocation1</location> <enabled>true</enabled> </category> <category> <name>def</name> <location>mylocation2</location> <enabled>true</enabled> </category> </myroot>
Comments
Post a Comment