简体   繁体   中英

SyndicationFeed AttributeExtensions namespace prefix

I'm adding some custom iTunes podcast tags to a RSS Feed.

        feed.AttributeExtensions.Add(new XmlQualifiedName(itunesPrefix, 
            "http://www.w3.org/2000/xmlns/"), itunesNs);

        var extensions = feed.ElementExtensions;

        extensions.Add(new SyndicationElementExtension("category", itunesNs, "Business"));

        var categoryElem = XName.Get("category", itunesNs);

        extensions.Add(
            new XElement(categoryElem,
                new XAttribute("text", "Sports & Recreation"),
                    new XElement(categoryElem,
                        new XAttribute("text", "Amateur")
                    )
            ).CreateReader()
        );

The output is:

<itunes:category>Business</itunes:category>
<category text="Sports &amp;amp; Recreation" xmlns="http://www.itunes.com/dtds/podcast-1.0.dtd">
  <category text="Amateur">
  </category>
</category>

Why is it that SyndicationElementExtension correctly adds the namespace prefix "itunes" but passing an XmlReader instance does not?

The output I expected is:

<itunes:category text="Sports &amp;amp; Recreation">
  <itunes:category text="Amateur">
  </itunes:category>
</itunes:category>

您知道我发现最简单的方法是正常创建它,然后使用Feedburner将其提交到iTunes并使iTunes兼容。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM