如何使用自定义命名空间创建 SyndicateFeed
如何生成包含下图中显示的命名空间的 Atom Feed? Atom feed 的所有节点都必须以“a:”开头。
这是我现在正在做的事情,但它不起作用。
SyndicationFeed feed = new SyndicationFeed();
XmlQualifiedName key = new XmlQualifiedName("os", "xmlns");
feed.AttributeExtensions.Add(key, "http://a9.com/-/spec/opensearch/1.1/");
谢谢!
How can I generate Atom Feed which will contain the namespaces displayed in the image below? All the nodes of the Atom feed have to start with "a:".
Here is what I am doing right now, however it doesn't work.
SyndicationFeed feed = new SyndicationFeed();
XmlQualifiedName key = new XmlQualifiedName("os", "xmlns");
feed.AttributeExtensions.Add(key, "http://a9.com/-/spec/opensearch/1.1/");
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信应该是
更新:
在更仔细地阅读您的问题后,我相信您可以通过覆盖 WriteStartElement 和 WriteStartAttribute XmlWriter 的方法Atom10FeedFormatter 使用的 实例。您可以通过实现自定义 XmlWriter 类来完成此操作,如下例所示。
将自定义类与 Atom10FeedFormatter 结合使用
会生成期望的输出
I believe it should be
UPDATE:
After reading your question more carefully, I believe you could accomplish this by overriding the WriteStartElement and WriteStartAttribute methods of the XmlWriter instance used by the Atom10FeedFormatter. You can do this by implementing a custom XmlWriter class like the example below.
Using your custom class with the Atom10FeedFormatter
produces the desired output