在dotnet 3.5中使用SynicationFeed类时,如何在每个syndicationitem之后插入新行?

时间:2009-11-25 12:15:27

标签: .net rss

在dotnet 3.5中使用SynicationFeed类时,如何在每个syndicationitem之后插入新行?

当你看到googlebot fetch的结果(在网站管理员中)时,它就是ONE LINE !!!!!!

1 个答案:

答案 0 :(得分:0)

创建XMLWriter时,可以将一些XMLWriterSettings传递给构造函数,并将indent属性设置为true。这将格式化您的代码。以下是使用AtomFormatter创建订阅源和项目的示例。我没有填写任何可读日期的Feed和项目。

//Create your feed and fill with data
SyndicationFeed feed = new SyndicationFeed();

//Create an item and fill with data
SyndicationItem item = new SyndicationItem();

//Add item to list and add list to feed
List<SyndicationItem> items = new List<SyndicationItem>();
feed.Items = items;

//Create XML file and serialize feed with XMLWriterSettings to indent code
XmlWriter writer = XmlWriter.Create("D:\\MyTestFile.xml", new XmlWriterSettings { Indent = true });
Atom10FeedFormatter formatter = new Atom10FeedFormatter(feed);
formatter.WriteTo(writer);
writer.Close();