私はSyndicationFeedを書き込むのと同じXmlWriterにxml-stylesheet
処理命令を書いても問題はありません。サンプルコード
SyndicationFeed feed = new SyndicationFeed("Test Feed", "This is a test feed", new Uri("http://http://example.com/testfeed"), "TestFeedID", DateTime.Now);
SyndicationItem item = new SyndicationItem("Test Item", "This is the content for Test Item", new Uri("http://example.com/ItemOne"), "TestItemID", DateTime.Now);
List<SyndicationItem> items = new List<SyndicationItem>();
items.Add(item);
feed.Items = items;
using (XmlWriter xw = XmlWriter.Create(Console.Out, new XmlWriterSettings() { Indent = true }))
{
xw.WriteStartDocument();
xw.WriteProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"sheet.xsl\"");
Atom10FeedFormatter atomFormatter = new Atom10FeedFormatter(feed);
atomFormatter.WriteTo(xw);
xw.Close();
}
は、コンソールとあなたがたXmlWriterに書き込みができる任意の宛先に書くことができます同じように
<?xml-stylesheet type="text/xsl" href="sheet.xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text">Test Feed</title>
<subtitle type="text">This is a test feed</subtitle>
<id>TestFeedID</id>
<updated>2011-08-02T13:19:12+02:00</updated>
<link rel="alternate" href="http://http//example.com/testfeed" />
<entry>
<id>TestItemID</id>
<title type="text">Test Item</title>
<updated>2011-08-02T13:19:12+02:00</updated>
<link rel="alternate" href="http://example.com/ItemOne" />
<content type="text">This is the content for Test Item</content>
</entry>
</feed>
を書き込みます。
これはずっと簡単です。私はもっと良い方法があったに違いないことを知っていましたが、これは私の前に置かれているので、これはかなり明白です。ありがとう! – Matt