<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/"> <channel> <item> <title>this is title</title> <description>about us</description> <category/> <link>www.google.co.in</link> </item> <item> <title>Home</title> <description>Home page</description> <category>web<category/> <link>www.yahoo.com</link> </item> </channel> </rss>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" media-type="text/xml; charset=UTF-8" /> <xsl:template match='/'> <root version="2.0" xmlns:test="http://search.yahoo.com/mrss/"> <xsl:for-each select="rss/channel/item"> <xsl:element name="test:item"> <xsl:if test="title !=''"> <xsl:attribute name ="title"> <xsl:value-of select="title"/> </xsl:attribute> </xsl:if> <xsl:if test="description !=''"> <xsl:attribute name ="description"> <xsl:value-of select="description"/> </xsl:attribute> </xsl:if> <xsl:if test="category !=''"> <xsl:attribute name ="category"> <xsl:value-of select="category"/> </xsl:attribute> </xsl:if> <xsl:if test="link !=''"> <xsl:attribute name ="link"> <xsl:value-of select="link"/> </xsl:attribute> </xsl:if> </xsl:element> </xsl:for-each> </root> </xsl:template> </xsl:stylesheet>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)