rss en xslt

Overzicht Reageren

Anna Mary

Anna Mary

09/06/2009 10:39:00
Quote
Ik ben sinds gisteren bezig met xml en xslt, xml in de vorm van rss. Mijn vraag: kan ik doormiddel van xslt een vorige/volgende knop aanmaken als de aantal nodes(feeds) boven de 5 zijn. En hoe? Ik heb w3schools geraadpleegd voordat ik hiermee begon, maar ik kon niet echt iets bruikbaars vinden. Google heeft me ook niet echt veel opgeleverd.

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="testrss.xsl"?>
<rss version="2.0">

<channel>
<item>
  <title>W3Schools Home Page</title>
  <link>http://www.w3schools.com</link>
  <description>Free web building tutorials</description>
  </item>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.w3schools.com/rss</link>
    <description>New RSS tutorial on W3Schools</description>
  </item>
  <item>
    <title>XML Tutorial</title>
    <link>http://www.w3schools.com/xml</link>
    <description>New XML tutorial on W3Schools</description>
  </item>
  <item>
    <title>CSS Tutorial</title>
    <link>http://www.w3schools.com/css</link>
    <description>New CSS tutorial on W3Schools</description>
  </item>
  <item>
    <title>JS Tutorial</title>
    <link>http://www.w3schools.com/js</link>
    <description>New JavaScript tutorial on W3Schools</description>
  </item>
  <item>
    <title>Some Tutorial</title>
    <link>http://www.w3schools.com/</link>
    <description>New Something tutorial on W3Schools</description>
  </item>
  <item>
    <title>Some 1 Tutorial</title>
    <link>http://www.w3schools.com/</link>
    <description>New Something 1 tutorial on W3Schools</description>
  </item>
  <item>
    <title>Some 2 Tutorial</title>
    <link>http://www.w3schools.com/</link>
    <description>New Something 2 tutorial on W3Schools</description>
  </item>
  <item>
    <title>Some 3 Tutorial</title>
    <link>http://www.w3schools.com/</link>
    <description>New Something 3 tutorial on W3Schools</description>
  </item>
  <item>
    <title>Some 4 Tutorial</title>
    <link>http://www.w3schools.com/</link>
    <description>New Something 4 tutorial on W3Schools</description>
  </item>
  <item>
    <title>Some 6 Tutorial</title>
    <link>http://www.w3schools.com/</link>
    <description>New Something 6 tutorial on W3Schools</description>
  </item>
  <item>
    <title>Some 7 Tutorial</title>
    <link>http://www.w3schools.com/</link>
    <description>New Something 7 tutorial on W3Schools</description>
  </item>
  <item>
    <title>Some 8 Tutorial</title>
    <link>http://www.w3schools.com/</link>
    <description>New Something 8 tutorial on W3Schools</description>
  </item>
  <item>
    <title>Some 9 Tutorial</title>
    <link>http://www.w3schools.com/</link>
    <description>New Something 9 tutorial on W3Schools</description>
  </item>
  <item>
    <title>Some 10 Tutorial</title>
    <link>http://www.w3schools.com/</link>
    <description>New Something 10 tutorial on W3Schools</description>
  </item>
</channel>

</rss>


Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <html>
  <head>
  <title></title>
  </head>
  <body>
  <xsl:for-each select="rss/channel/item">
  <a>
    <xsl:attribute name="href">
        <xsl:value-of select="link" />
    </xsl:attribute>
    
    <xsl:value-of select="title" />
  </a>
  <br />
   <xsl:value-of select="description" />
   <br />
   <br />
   </xsl:for-each>
  
   <a>
   <xsl:number value="count(rss/channel/item)"/>

   </a>

  </body>
  </html>
</xsl:template>
</xsl:stylesheet>


edit--
Ik d8 misschien zo iets?!
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
<xsl:variable name="count">
<xsl:number value="count(rss/channel/item)"/>
</xsl:variable >
<xsl:if test="$count &gt; 5">
show
</xsl:if>



edit2--
Ik heb iets gevonden: http://www.biglist.com/lists/xsl-list/archives/200101/msg00114.html

Maar het is mij nog onduidelijk hoe ik dit zou kunnen gebruiken?
Gewijzigd op 01/01/1970 01:00:00 door Anna Mary
 
PHP hulp

PHP hulp

03/09/2010 01:26:34
Gesponsorde koppelingen:
 
Er zijn nog geen reacties op dit bericht.



Overzicht Reageren