Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML output. 1

Status
Not open for further replies.

Work23

Technical User
Mar 8, 2005
94
US
Hello, I am new to using XML. I was curious to know how to make a HTML output from a an XML file generated from an RSS aggregator. I need to make an html web page that lists updated information from the RSS aggregator. I am confused as to how to go about this. If you could please share your thoughts or maybe direct me some where else that explains this functionality well. Thanks so much! Take care.
 
Give me an rss link you want to use and I'll post an example
 
OK, there's a few ways to do this. The best way is to do it server-side if you know ASP or PHP or something. You could use javascript to transform client-side, or you can do it this way:

Create a dummy XML file (called 'rss.xml'):
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="rss.xsl"?>
<rss/>
Then save this stylesheet as 'rss.xsl':
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:template match="/">
    <html>
      <head>
        <title>RSS test</title>
      </head>
      <body>
        <h1>RSS news:</h1>
        <xsl:apply-templates select="document('[URL unfurl="true"]http://rss.cnn.com/rss/cnn_topstories.rss')/rss/channel/item"/>[/URL]
      </body>
    </html>
  </xsl:template>
  <xsl:template match="item">
    <hr/>
    <h2>
      <a href="{link}">
        <xsl:value-of select="title"/>
      </a>
    </h2>
    <p>
      <xsl:value-of select="description"/>
    </p>
    <p style="font-style: italic">
      <xsl:value-of select="pubDate"/>
    </p>
  </xsl:template>
</xsl:stylesheet>
Then open the XML file in a browser.
 
Thank you very much. I really appreciate this. I'm sorry if this seems like an obvious question, but still a little confused. What exactly would I be using to implement this to allow it to be a functioning web page? Thanks again so much!
 
Have you got it to work? Save the files in any text-editor (notepad will do but not as .txt file). Double-click on the xml file to open in internet explorer. All it takes to implement is internet explorer.

Jon

"There are 10 types of people in the world... those who understand binary and those who don't.
 
Yes,that worked great! Thanks so much for you help. This will allow the page to be updated based on the new "news" created by the rss link? Thanks so much! I really appreciate this.
 
This worked really well. I had one more question. I tried to make this work on the web. So I referenced the links on the web page created to these files. When I click on the xml file. I get this error:
"The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later."

Is there anything I can do to correct that? Please let me know. Thanks so much.

 
What does it say underneath that error?

Jon

"There are 10 types of people in the world... those who understand binary and those who don't.
 
Any idea on anything that I can do to get past this error?:

"The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later."
"Access is denied"

I'm not exactly sure what next step I can take. Thanks so much! Take care.
 
Check the permissions set on the files

Jon

"There are 10 types of people in the world... those who understand binary and those who don't.
 
I actually have full permission over the files. I tried to embed the code with some html and I still get errors. I think I lack the understanding of how to make this work within at HTML page. Is there something that I need to do in order for XML to generate? Thanks a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top