简体   繁体   中英

SyndicationElementExtension with namespace

I want to get this result:

<someNSalias:full-text>Good news everyone!</someNSalias:full-text>

so i'm writing a code:

var elm = new SyndicationElementExtension(field.Name, field.HasNamespace ? RssNs : string.Empty,field.Value);
result.ElementExtensions.Add(elm);

but i get:

<full-text xmlns="someNS">Good news everyone!</full-text>

what am I doing wrong?

Solved: should add this NS localy (in feed as Attribute), and remove it when all's done

Ex:

        var feed = new SyndicationFeed(Config.Title, Config.Description, new Uri(Config.Link), Config.ListUrl, DateTime.Now)
        {
            ImageUrl = new Uri(Config.ImageUrl),
            Generator = GetType().BaseType.FullName + "Generator"
        };

        feed.AttributeExtensions.Add(new XmlQualifiedName(RssNs, XNamespace.Xmlns.NamespaceName), Url);

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