![]() |
|
|
Published: Wednesday, June 07, 2000 By Brandon Monahan
In Part 3 we looked at some of the more advanced abilities of XSL, such as how to iterate through XML nodes and how to display hyperlinks. In this part we'll look at one possible way to use XSL to display the XML generated by iSyndicate.com!
Now we have got the ability to loop through our XML, we can display all kinds of data and make hyperlinks. What more do you need to know? Here is the finished XSL document using all of the information above (by the way, the header, stylesheet, and template tags are all necessary for any XSL document transferring the HTML):
This code will simply loop through the channels displaying the channel name, then inside loop through the headlines in that channel giving the headline name and a link to the news. To see this XSL stylesheet in action be sure to view the live demo!
How do I Make it All Work?
In the above code we had initiated the XML DOM object and loaded the external XML document. Now let's instantiate the XSL DOM object and load our XSL document like such:
Now we are almost finished. All we have to do is write the parsed XML to the page and clean up like such:
That's that. Your XML should be written to the page as a beautifully formatted block of news stories (html). More likely than not, you will get a blank screen. Here is how to fix that.
Debugging There are a couple of problems you may run into like not having the proper settings on the server to let your program load a document from another site. If you can't make it run on your server but you are sure you have the code correct give it a try on PWS (PWS doesn't have the features of such complicated security and should run the page) or save the XML file to a local disk and give it a try.
Final Product Good Luck and Happy Programming! If you have any questions, problems, or what-not, please do feel free to drop me a line at: bwm4@yahoo.com. If you found this article interesting be sure to check out the related articles listed below... Brandon Monahan
Attachments: home_News.xslhome_News.asp in text format
(this ASP page utlizes home_News.xsl to display the syndicated news)
Related Articles
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||