c# - OPML Parser

by brunofig 19. September 2006 21:33
Well, I needed a opml parser for the widget i'm currently building using the mooTools. Since I couldn't found one that was standalone, i decided to do one.

The code is simple to use. It can be done in to ways: Parse a existing file, or create a new structure and the save it.

Let's parse one :

//Parse a existing file
Opml data = Opml.Parse(Server.MapPath("app_Data/Data.opml"));

Now that I've got the opml structure, let's add a new outline:

// add new outline
OpmlOutline myOutline = new OpmlOutline();
myOutline.Text = "CreativeMinds Blog";
myOutline.Title = "CreativeMinds Blog";
myOutline.Description = "CreativeMinds - because we all have one...";
myOutline.HtmlUrl = new Uri("http://www.brunofigueiredo.com");
myOutline.XmlUrl = new Uri("http://www.brunofigueiredo.com/rss.aspx");
data.AddOutline(myOutline);

For navigate the outline, you can use the new functionality of the generics lists, the foreach:

// navigate the outlines
data.Outlines.ForEach(delegate(OpmlOutline outline)
{
Response.Write(outline.Text + "<br>");
});


In the end,  you can save to a file:
// save to a new file
data.Save(Server.MapPath("app_Data/clone.opml"));


The download can be done where.

Be the first to rate this post

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

Tags:

Comments

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.7
Theme by Mads Kristensen

About the author

Hi!

My name is Bruno and I'am a senior consultant. When I'm not working, you can catch me playing with my daugther, taking photos and hanging out with my wife and friends. :)

You can also check my dark side or have fun with my vision of the world.

View Bruno Figueiredo's profile on LinkedIn

TwitterCounter for @brunoshine
 
Creative Commons License

 
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
 

Ads

    Page List

      Most comments

      Busby SEO Test Busby SEO Test
      2 comments
      kh Cambodia
      laptop cases laptop cases
      2 comments
      Busby SEO Test Busby SEO Test
      1 comments

      RecentComments

      Comment RSS

      Popuri.us

      My Popularity (by popuri.us)