Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

xsl to format xml news

Posted on 2013-05-28
5
Medium Priority
?
311 Views
Last Modified: 2013-05-29
Dear all,
Could you please help to write xsl to format news feed from http://www.itp.net/arabic/rss/?tid=2


thanks
0
Comment
Question by:ethar1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 39203245
If you looking for hiring a developer to do this, contact me through the information found on my profile page

If you want a solution from this forum. At least let us now what you mean by formatting.
Do you need to make HTML from these pages?

Then this could be a first step

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:atom="http://www.w3.org/2005/Atom"
    version="1.0">
    
    <xsl:template match="/rss">
        <html>
            <head/>
            <body>
                <xsl:apply-templates select="channel"/>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template match="channel">
        <h1><a href="{link}"><xsl:value-of select="title"/></a></h1>
        <xsl:apply-templates select="item"/>
    </xsl:template>
    
    <xsl:template match="item">
        <h3><a href="{link}"><xsl:value-of select="title"/></a></h3>
        <p><xsl:value-of select="pubDate"/></p>
        <p><xsl:apply-templates select="description"/></p>
        <xsl:if test="enclosure[contains(@type, 'image')]">
            <img src="{enclosure/url}"/>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="description">
        <xsl:value-of select="." disable-output-escaping="yes"/>
    </xsl:template>
    
</xsl:stylesheet>

Open in new window

0
 

Author Comment

by:ethar1
ID: 39204238
excellent , this is exactly what I need...
Just could you please tell me how to select top 5 items (news ) only?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39204292
if you change line 17
<xsl:apply-templates select="item"/>

into

<xsl:apply-templates select="item[position() &lt;= 5]"/>

you will get the top 5 only
0
 

Author Comment

by:ethar1
ID: 39205874
Thanks you very much...

How can remove any html tag from the description element?
I add another question for you ...
Please response.
http://www.experts-exchange.com/Hardware/Components/Q_28142256.html
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39205930
welcome
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As you can read I recycle all my old hardware and the time has come that my power supply of 200 Watt cannot provide enough power for my backup server. I have lots of Compaq power supply's laying around, so I figured to use one of these PSU's. I t…
System overheating may become a serious problem if not taken care of at the proper time. I am writing this article because I faced a similar problem. Intro All electronic devices produce heat, but computers are a special case - the processors bo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question