BizTalk Utilities CV ,   Jobs ,   Code library
 
Go to the front page to continue learning about XML or select below:

Contents

ReBlogger Contents

Previous posts in .NET XML, System.XML

 
 
Page 4319 of 18321

XML namespace declarations in SyndicationFeed objects

Blogger : MSDN Blogs
All posts : All posts by MSDN Blogs
Category : .NET XML, System.XML
Blogged date : 2008 Jan 16

Following on the heels of Steve Maine's post about namespaces in Syndication objects (Feeds, items, etc.), I thought it wise to plug the new stuff in PictureServices.

At the moment, PictureServices implements SLE (Simple List Extensions), and does a pretty crude job of it at that. Time permitting, I will add more support for field and group customization. For now, it serves as an example more than a carrier grade implementation. In any event, I used extension methods in the following type definition to make it easy to insert the right namespace declarations in the feed:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Syndication;
using System.Xml;

namespace Microsoft.DPE.Samples.SyndicationExtensions
{
    // adds custom namespaces to an item or a feed
    public static class SyndicationNamespaceHelper
    {
        public static void DeclareNamespace(this SyndicationFeed feed, 
String prefix,
String ns) { XmlQualifiedName key = new XmlQualifiedName(prefix, NamespaceUris.XMLNamespace); feed.AttributeExtensions.Add(key, ns); } public static void DeclareNamespace(this SyndicationItem item,
String prefix,
String ns) { XmlQualifiedName key = new XmlQualifiedName(prefix, NamespaceUris.XMLNamespace); item.AttributeExtensions.Add(key, ns); } } }

The usage model is simple - just new up a feed or an item, then call DeclareNamespace. Piece of cake.


Read comments or post a reply to : XML namespace declarations in SyndicationFeed objects
Page 4319 of 18321

Newest posts
 

    Email TopXML