Wednesday, April 25, 2012

How to Get all xml Items using xslt

Before doing this task i don't have an idea about xslt .Xslt is easy to learn and  to develop. Here i will show how to get the all XML items and display the items as list of anchor at client side view.For this i will use for loop to get the XML data

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">  
    <xsl:template match="/">
        <xsl:for-each select="List/Item">           
                <a>
                    <xsl:attribute name="href">
                        <xsl:text>#</xsl:text>
                    </xsl:attribute>
                    <xsl:attribute name="title">
                        <xsl:text>Title</xsl:text>
                    </xsl:attribute>
                    <xsl:attribute name="target">
                        <xsl:text>blank</xsl:text>
                    </xsl:attribute>                   
                    <img>
                        <xsl:attribute name="src">
                            <xsl:value-of select="href"/>
                        </xsl:attribute>
                        <xsl:attribute  name="alt">
                            <xsl:value-of select="Title"/>
                        </xsl:attribute>
                        <xsl:attribute  name="class">
                            <xsl:text>slider_img</xsl:text>
                        </xsl:attribute>
                    </img>
                    <span>
                        <b>
                            <xsl:value-of select="Title"/>
                        </b>                       
                        </span>
                </a>               
        </xsl:for-each>    </xsl:template>  
</xsl:stylesheet>

No comments:

Bel