有什么区别吗
<opensearch:totalResults>1000</opensearch:totalResults>
and
<totalResults xmlns="opensearch">1000</totalResults>
我使用 .NET 中的 SyndicateFeed 类来生成 Atom 提要,并且我需要为 opensearch 标准添加一些元素,但当我希望它像前一个一样添加元素时,它会不断添加像上面后一个元素一样的元素。
代码:
feed.ElementExtensions.Add("totalResults", "opensearch", "2");
EDIT
根 feed 标签如下所示
<feed xml:lang="en-US" p1:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:p1="xmlns" xmlns="http://www.w3.org/2005/Atom">
按照@Reddog的建议更改我的代码后,totalresults元素看起来像这样
<totalResults xmlns="http://a9.com/-/spec/opensearch/1.1/">1000</totalResults>
将命名空间添加到 feed 标签的代码如下所示
feed.AttributeExtensions.Add(
new XmlQualifiedName("opensearch", "xmlns"),
@"http://a9.com/-/spec/opensearch/1.1/");
添加totalresults元素的代码现在看起来像这样
feed.ElementExtensions.Add("totalResults", @"http://a9.com/-/spec/opensearch/1.1/", "1000");