Sign in
Windows Forms Documentation Updates
We're the Windows Forms User Education team at Microsoft. We use this space to update folks on developments with Windows Forms docs, publishing doc updates before they're published. Feel free to ask us questions about WinForms, and we'll do our best to an
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
Blog Home
About
Email Blog Author
Share this
RSS for posts
Atom
RSS for comments
Search
Tags
Application Settings
ClickOnce
Container Controls and Layout
Crossbow
Data Binding
DataGridView
ElementHost
Form and Application Classes
Pages
ToolStrip Control
WebBrowser, HTML, Networking
Windows Forms Globalization and Localization
WindowsFormsHost
WPF
XML, XSL & RSS
Archive
Archives
May 2008
(1)
January 2008
(1)
December 2007
(5)
September 2007
(1)
June 2007
(1)
May 2007
(4)
April 2007
(3)
February 2007
(1)
November 2006
(1)
October 2006
(2)
August 2006
(3)
July 2006
(5)
June 2006
(7)
May 2006
(4)
April 2006
(10)
March 2006
(10)
February 2006
(6)
January 2006
(5)
Retrieve <?xml-stylesheet> from RSS Feed using XmlDocument
MSDN Blogs
>
Windows Forms Documentation Updates
>
Retrieve <?xml-stylesheet> from RSS Feed using XmlDocument
Retrieve <?xml-stylesheet> from RSS Feed using XmlDocument
Jay A. Allen
2 Aug 2006 6:50 PM
Comments
0
So I'm trying to wrap up this white paper I'm writing on consuming RSS in Windows Forms. I wrote a whole section on how to apply a custom XSLT transform to a feed, and display the resulting HTML in the WebBrowser. (
I gave a less-complete version of a solution in an earlier blog post
.) Then it hit me: "Jay, you fool - what if the RSS feed already
has
a stylesheet associated with it?"
Fortunately, factoring this into your logic is simple. You can use XmlDocument, SelectSingleNode(), and a rather funky-looking XPath command to test whether the feed has a stylesheet. If it does, you can pass it straight to the WebBrowser control for rendering, with no further processing required.
XmlDocument doc = new XmlDocument();
try
{
doc.Load("http://blogs.msdn.com/winformsue/rss.xml");
}
catch (Exception ex)
{
MessageBox.Show("Could not load XML file. Error: " + ex.Message);
return;
}
XmlProcessingInstruction node = (XmlProcessingInstruction)doc.SelectSingleNode("/processing-instruction(\"xml-stylesheet\")");
if (node != null)
{
webBrowser1.Url = new Uri("http://blogs.msdn.com/winformsue/rss.xml");
}
else
{
// Apply custom style.
}
0 Comments
WebBrowser, HTML, Networking
,
XML, XSL & RSS
Blog - Comment List MSDN TechNet
Comments
Loading...