Show All Content in XSLT

I have already shown how you can display all attributes and their values from a XSLT content, but in case you want to look at the whole structure plus their attributes, you can use this instead:

   1: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl asp" xmlns:asp="System.Web.UI.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
   2:     <xsl:output method="html" />
   3:     <xsl:template match="*">
   4:         <xsl:param name="path" select="''" />
   5:         <xsl:variable name="previous" select="count(preceding-sibling::*[name()=name(current())])" />
   6:         <xsl:variable name="countprevious" select="count(following-sibling::*[name()=name(current())])" />
   7:         <xsl:variable name="fullpath" select="concat($path, '/', name(), substring(concat('[', $previous + 1, ']'), 1 div ($countprevious or $previous)))" />
   8:         <p><xsl:value-of select="$fullpath" /></p>
   9:         <xsl:apply-templates select="@*|*">
  10:             <xsl:with-param name="path" select="$fullpath" />
  11:         </xsl:apply-templates>
  12:     </xsl:template>
  13:     <xsl:template match="@*">
  14:         <xsl:param name="path" select="''" />        
  15:         <xsl:value-of select="concat($path, '/@', name())" />: <xsl:value-of select="." />
  16:         <br/>
  17:     </xsl:template>
  18: </xsl:stylesheet>

                             

No Comments

Add a Comment

As it will appear on the website

Not displayed

Your website