Microformat.net

I would like to take this opportunity to announce that I have created a usable [although beta] release of a generic Microformat parser for .Net. I don’t know of any other frameworks that easily allow you to find Microformats in an html/XML stream that are specifically built for .Net, so I believe that this project is a first (and hopefully a de-facto choice in time to come).
The project can be found on Codeplex at [http://www.


This content originally appeared on Modern Web Development with Chrome and was authored by Paul Kinlan

<p>I would like to take this opportunity to announce that I have created a usable [although beta] release of a generic Microformat parser for .Net.  I don't know of any other frameworks that easily allow you to find Microformats in an html/XML stream that are specifically built for .Net, so I believe that this project is a first (and hopefully a de-facto choice in time to come).</p> <p>The project can be found on Codeplex at [http://www.codeplex.com/microformat](http://www.codeplex.com/microformat).  The current release is Iteration 3. </p><p>The parser is stream based and uses an application configuration (see below for an example) to define the how the parser should parse the html/XML stream.  This flexible configuration means that if a spec changes for a Microformat or a new one is introduced then no code needs to be changed in the framework to let users of the framework see the changed data. </p><div class="CodeRay"> <div class="code"><pre><configuration> <configSections> <section name='MicroformatsSection' type='Microformats.ConfigurationSections.MicroformatConfigSection, Microformat.net'/> </configSections> <MicroformatsSection> <Microformats> <Microformat type='rel-tag' rootType='rel' root='tag' dataType='System.Uri' /> <Microformat type='hCard' rootType='class' root='vcard' dataType='System.String'> <Fields> <Field name='fn' dataType='System.String' plurality='Singular'/> <Field name='url' dataType='System.Uri' plurality='Singular'/> <Field name='email' dataType='System.Uri' plurality='Singular'/> <Field name='adr' dataType='Microformat' plurality='Singular'/> </Fields> </Microformat> <Microformat type='adr' rootType='class' root='adr' dataType='System.String'> <Fields> <Field name='post-office-box' dataType='System.String' plurality='Singular'/> <Field name='extended-address' dataType='System.String' plurality='Singular'/> <Field name='street-address' dataType='System.String' plurality='Singular'/> <Field name='locality' dataType='System.String' plurality='Singular'/> <Field name='region' dataType='System.String' plurality='Singular'/> <Field name='postal-code' dataType='System.String' plurality='Singular'/> <Field name='country-name' dataType='System.String' plurality='Singular'/> </Fields> </Microformat> </Microformats> </MicroformatsSection></pre></div> </div> <a href="http://11011.net/software/vspaste"></a><p>The above configuration says that the following Microformats are to be searched for: rel-tag, hCard and adr.  Each Microformat configuration can also be nested (see the hCard spec that allows an adr to be nested inside itself).  This saves on duplicating configuration information.  (Unfortunately a circular reference in the configuration can be defined and plurality of elements is not implemented.  This will be fixed soon).  Currently in this configuration not all of the hCard spec is defined (this was done for simplicity of me showing you how the config works), obviously this means that any parts of a Microformat that you are not interested in you won't see in the output of the framework. </p><p>The code that follows shows how easy it is to use this framework:</p><div class="CodeRay"> <div class="code"><pre>using (TextReader ms = new StringReader(@'<html><body><div class=''vcard author''> <a class="">Paul Kinlan</a> <a class="">paul.kinlan@gmail.com</a> <div class=''adr''> <span class=''locality''>Liverpool</span>,<span class=''region''>Merseyside</span> </div></div></div><a href="" />Test Tag</a></body></html>')) { using (Microformats.Readers.MicroformatReader mr = new Microformats.Readers.MicroformatReader(ms)) { Microformat m = null; while(( m = mr.Read()) != null) { Console.Out.Write('Found Microformat: ' + m.Name + '. Machine Value:' + m.MachineValue + '\n'); foreach (IField f in m.Fields) { Console.Out.WriteLine('\t' + f.Name + ': ' + f.MachineValue); } } } }</pre></div> </div> <a href="http://11011.net/software/vspaste"></a><p>The first line, simply converts makes a TextReader object that can be used to pass into the MicroformatReader object.  Once the stream has been presented to the framework, then it is as simple as calling mr.Read to iterate to across all the valid Microformats in the document.  The Read() method returns fully constructed Microformat objects that can be examined and used directly in your programs.</p><p>I still have a lot of work to do, however it appears (to me at least) to be quite flexible.  I would greatly appreciate any comments and feedback and if you use the framework I would love to hear about it.  If anyone is interested in joining the project let me know. <p /></p><div class="wlWriterSmartContent" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px;">Topicala Tags: <a href="http://www.topicala.com/tag/c#" rel="tag">c#</a> [[OPML](http://www.topicala.com/opml/c#.opml)], <a href="http://www.topicala.com/tag/microformat" rel="tag">microformat</a> [[OPML](http://www.topicala.com/opml/microformat.opml)], <a href="http://www.topicala.com/tag/microformats" rel="tag">microformats</a> [[OPML](http://www.topicala.com/opml/microformats.opml)], <a href="http://www.topicala.com/tag/.net" rel="tag">.net</a> [[OPML](http://www.topicala.com/opml/.net.opml)], <a href="http://www.topicala.com/tag/framework" rel="tag">framework</a> [[OPML](http://www.topicala.com/opml/framework.opml)], <a href="http://www.topicala.com/tag/api" rel="tag">api</a> [[OPML](http://www.topicala.com/opml/api.opml)], <a href="http://www.topicala.com/tag/codeplex" rel="tag">codeplex</a> [[OPML](http://www.topicala.com/opml/codeplex.opml)]</div>


This content originally appeared on Modern Web Development with Chrome and was authored by Paul Kinlan


Print Share Comment Cite Upload Translate Updates
APA

Paul Kinlan | Sciencx (2007-09-08T00:00:00+00:00) Microformat.net. Retrieved from https://www.scien.cx/2007/09/08/microformat-net/

MLA
" » Microformat.net." Paul Kinlan | Sciencx - Saturday September 8, 2007, https://www.scien.cx/2007/09/08/microformat-net/
HARVARD
Paul Kinlan | Sciencx Saturday September 8, 2007 » Microformat.net., viewed ,<https://www.scien.cx/2007/09/08/microformat-net/>
VANCOUVER
Paul Kinlan | Sciencx - » Microformat.net. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2007/09/08/microformat-net/
CHICAGO
" » Microformat.net." Paul Kinlan | Sciencx - Accessed . https://www.scien.cx/2007/09/08/microformat-net/
IEEE
" » Microformat.net." Paul Kinlan | Sciencx [Online]. Available: https://www.scien.cx/2007/09/08/microformat-net/. [Accessed: ]
rf:citation
» Microformat.net | Paul Kinlan | Sciencx | https://www.scien.cx/2007/09/08/microformat-net/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.