Einzelnen Beitrag anzeigen

Assertor

Registriert seit: 4. Feb 2006
Ort: Hamburg
1.296 Beiträge
 
Turbo C++
 
#6

Re: Inhalte einer TListView auf eine Webseite anzeigen???

  Alt 11. Okt 2008, 13:53
Nachtrag mit einem kurzen Beispiel, damit Du die Logik verstehst:

Du hast Deine XML-Datei, z.B.
XML-Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="template.xsl" ?> // dies muß in die Datei, damit der Browser es automatisch umwandelt
<test>
 <titel>Dateiendungen</titel>
 <glossar>
  <eintrag>
   <begriff>bak</begriff>
   <bedeutung>Backup-Datei</bedeutung>
  </eintrag>

  <eintrag>
   <begriff>bmp</begriff>
   <bedeutung>Bitmap-Grafik</bedeutung>
  </eintrag>
 </glossar>
</test>
und Deine template.xsl, z.B.
XML-Code:
<?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="/">
 <html>
 <head>
 </head>
 <body>
  <xsl:apply-templates />
 </body>
 </html>
</xsl:template>

<xsl:template match="titel">
 <h1><xsl:value-of select="." /></h1>
</xsl:template>

<xsl:template match="glossar/eintrag">
 <p style="font-family:Arial,Helvetica,sans-serif; font-size:16px">
  <xsl:apply-templates />
 </p>
</xsl:template>

<xsl:template match="begriff">
 <b style="color:blue"><xsl:apply-templates />: [/b]
</xsl:template>

<xsl:template match="bedeutung">
  <xsl:value-of select="." />
</xsl:template>

</xsl:stylesheet>
Wenn Du nun das XML im Browser öffnest, wird das XSL automatisch darauf angewandt. Es wird dir nun statt XML formatiertes HTML ausgegeben (weil es so in der template.xsl definiert wird).

Gruß Assertor
Frederik
  Mit Zitat antworten Zitat