FOAF Parsing And Crawling In C#

Thursday, May 1, 2008 by Mistlee


Can't see any images? -!


C Programming Tutorials and advice
CProgrammingTrends News Archives About Us Feedback

Recent Articles

Working With Gravatar Images
Gravatar is a service that associates your e-mail addresses with a picture of you for use on blog comments, forums and bulletin boards. I've been a happy user for years. A cool thing about Gravatar...

ZoomInfo API - ASP.NET C#
Over the last couple of days I have been digging into the ZoomInfo API (using C# - ASP.Net) to first of all better understand the API and secondly to leverage the...

OpenID Implementation In C# & ASP.NET
Over the weekend I began looking more deeply into OpenID than I have before. I've always been intrigued by OpenID, but the information about it in terms...

IDataRecord Fields To Dictionary Extension Method
I have never been a fan of directly passing IDataRecords, or IDataReaders for that matter, about the place to get simple field values out. herefore, with the introduction...

ECMAScript, The New C++?
Everything but a call for a kitchen sink subroutine has been tossed into ECMAScript 4, leaving a couple of bloggers wondering why. ECMAScript has appeal...

Responses To Microsoft Releasing .NET 3.5 Source
So far the views from Dave, whurley, Matt and others have been negative to handle with caution. After I heard that Microsoft was releasing the .NET 3.5 source...

Resolve & Shorten URLs In C#
Recently I've needed a method that would look at some text and automatically discover all URLs and turn them into hyperlinks. I've done that before so it was...

Yahoo SiteExplorer API With C#
If you are interested in using Yahoo's SiteExplorer API and are coding in the ASP.NET environment using C# (web pages) then the following method might be of...



05.01.08

FOAF Parsing And Crawling In C#


By Mads Kristensen

I've been looking deeply into FOAF lately and last week I worked on a parser that could wrap a FOAF document into a strongly typed class for easy consumption by C#.

Now I want to share it with anyone interested. It appears there are no FOAF parsers available in C# yet. I wasn't able to find any.

The parser
The class FoafParser has two public methods, Parse and ParseFriendsAsync, which handles two different approaches in fetching FOAF documents.

The Parse method
This method takes a URL as a parameter which must point to an online FOAF document. It then parses the foaf:Person element which contains fields such as name, birth date, photo, homepage etc. It then looks for people in the FOAF document that are described as someone you know, parses the information available and adds it to a public collection property. The following example parses a FOAF document and binds it to an ASP.NET Repeater.



The ParseFriendsAsync method
When you list people you know in a FOAF document, it is common to only provide very little information such as the full name. When that is the case it is also common to provide a link to that persons FOAF document using the rdfs:seeAlso tag. We can then use that link to retrieve all your friend's FOAF documents and parse them as well.


It can take a long time to retrieve all those documents one at a time, but if we do it asynchronously then we can speed things up substantially. When you have called the Parse method on the FoafParser class, you can then call ParseFriendsAsync. It loops through all the friends that the Parse method found in search for the rdfs.seeAlso tag. When it finds it, a web request is made to retrieve the FOAF document of that friend and then parse it for information.

When the ParseFriendsAsync method is finished, it triggers an event you can listen to. All the friends with FOAF documents have now been updated in the collection.



Download
In the zip file below you'll find the FoafParser.cs class as well as an example .aspx page and code-behind file.

FoafTester.zip (3,77 kb)

Comments

About the Author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.

http://www.madskristensen.dk/
About CProgrammingTrends
A collection of articles and tutorials designed to help C and C variant programmers in their programming work. C Programming Tutorials and advice





CProgrammingTrends is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITmanagmentNews.com





-- CProgrammingTrends is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2008 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal


archives | advertising info | news headlines | free newsletters | comments/feedback | submit article


Unsubscribe from CProgrammingTrends.
To unsubscribe from CProgrammingTrends or any other iEntry publication, simply send an email request to: support@ientry.com
CProgrammingTrends Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact

0 comments: