extending RSS format with namespace and use it with IE7 RSS API


This is from my article writing. I used RSS to transport order data. The consumer is based on the IE7 RSS API. If you have never done this before read this blog

http://blogs.msdn.com/rssteam/archive/2006/06/08/621623.aspx

First i changed the RSS format to use namespace and prefix elements.

<rss version="2.0" xmlns:Orders="http://ppedv.com/Orders">
  <channel>
  
    <item>
      <description>Bestellung 29.Sept.2002
      </description>
      <pubDate>Sun, 29 Sep 2002 19:59:01 GMT</pubDate>
      <Orders:Anzahl>1</Orders:Anzahl>
      <Orders:Preis>23</Orders:Preis>
    </item>
...

Then i created a winforms application which uses the RSS API. I hooked into the Itemcount event sink.

   Sub NeueOrders(ByVal path As String, ByVal anz As Integer) Handles RSSevents.FeedItemCountChanged

In this i iterate thorugh all items. The standard attribute like title or link are propertys of item. But not the extend my ones. I copy the raw xml data from item to xmldocument. To use prefix in xpath expression (selectsinglenode) you have to inlcude a xmlnamespace Manager

 Dim a As String = tmpItem.Xml(FEEDS_XML_INCLUDE_FLAGS.FXIF_CF_EXTENSIONS)
            Dim xa As New Xml.XmlDocument
            xa.LoadXml(a)
            Dim nsMgr As New Xml.XmlNamespaceManager(xa.NameTable)
            nsMgr.AddNamespace("Orders", "
http://ppedv.com/Orders")
            anzahl = xa.SelectSingleNode("item/Orders:Anzahl", nsMgr).InnerText

Done! 

No Comments