글쎄 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