Passaggio all'ora legale 31 marzo 2024 02:00 03:00 sposta avanti l'orologio di 1 ora (si dorme 1 ora in meno)
L'esempio riportato permette di elencare tutti gli elementi del file xml semplicemente aprendo il file test.xml nel browser.
Con questa azione automaticamente, il browser, lo fonde con il file test.xsl producendo come risultato un file html.
Il risultato estetico non è il massimo, ma test.xsl permette di analizzare un file xml quando non si ha la possibilità di vederlo perché generato automaticamente da altri programmi.
XML: test.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl" ?>
<rss version="0.91">
   <channel att="aa">
      <title attrib1="1" attrib2="2" attrib3='3'>Esempio</title>
      <link>http://www.sgart.it</link>
      <description>Best site</description>
      <language>it-IT</language>
      <image>
         <title>Sgart.it</title>
         <url>http://sgart/images/logos/logo.gif</url>
         <link>http://www.sgart.it</link>
         <description>Esempio con XML e XSL</description>
         <width>160</width>
         <height>46</height>
      </image>
      <item>
         <title>Articoli</title>
         <link>http://sgart/Page/default.asp?id=4</link>
         <description>Raccolta di appunti</description>
      </item>
      <item>
         <title>C# .NET esempi</title>
         <link>http://sgart/Page/default.asp?id=23</link>
         <description>Raccolta di esempi</description>
      </item>
   </channel>
</rss>

XML: test.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
   <xsl:template match="/">
      <xsl:for-each select="//*">
         <h3>
            <xsl:for-each select="ancestor::*">
               <xsl:value-of select="name()"/> / 
            </xsl:for-each>
         </h3>
         <p>
            [<xsl:value-of select="name()"/>=<xsl:value-of select="."/>]
         </p>
         <xsl:for-each select="./@*">
            {<xsl:value-of select="name()"/>=<xsl:value-of select="."/>} | 
         </xsl:for-each>
         <hr />
      </xsl:for-each>
   </xsl:template>
</xsl:stylesheet>
I file devono essere nella stessa cartella
Potrebbe interessarti anche: