Using C# XmlNamespaceManager to AddNamespace

by top54u.com 12 Jul, 2008
Spotlight.....

XmlNamespaceManager is a C# class that can be used in ASP.Net web applications to Add Namespace for providing the meta-data information about XML schema. AddNamespace function accepts two parameters, first as string type prefix name and string type URL for the providing the location of xml namespace. These days RSS feeds are becoming popular for two purposes, one as a web site feed and second for Developer API of a web site. You can create your own RSS aggregators or RSS readers using features of XML namespace and its class methods and function in ASP.Net using C# code.

 

Examples of XML RSS Feed Namespaces

Yahoo.com media XML namespace

Yahoo has developed an XML namespace with name media. Its URL path for schema definitions is http://search.yahoo.com/mrss/. You can see its usage in Youtube RSS feeds for getting videos. It uses media namespace to generate the syndication containing:

  • media:title
  • media:description
  • media:keywords
  • media:category
  • media:thumbnails
  • media:player

 

 

A9.com openSearch XML namespace

Youtube API also syndicates RSS feeds having openSearch prefixed elements to display search result parameters such as:

  • openSearch:totalResults
  • openSearch:startIndex
  • openSearch:itemsPerPage

 

Namespace schema definition URL for A9.com openSearch is http://a9.com/-/spec/opensearchrss/1.0/.

 

You can use the following sample C# code to include the XML namespaces using XmlNamespaceManager class and AddNamespace function:

 

xmlN = new XmlNamespaceManager( XmlDataSource1. GetXmlDocument(). NameTable);

xmlN.AddNamespace( "media", "http://search.yahoo.com/mrss/" );

 

 

XmlDataSource1.GetXmlDocument().NameTable is passed as parameter to XmlNamespaceManager. You can pass the XML file path to XmlDataSource control through its DataFile property and then it can be used with XmlNamespaceManager object.

 

Next we will learn how to display the XML data items by passing the XmlNamespaeManager Object in ASP.Net Repeater Data Binding with Youtube API RSS.

Spotlight.....

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , , , , , , ,

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

8/23/2008 8:57:48 PM

OUR SPONSORS[+ advertise here]
related videos.....
recent posts.....
top54u ezines.....