Ufxtract

Powerful, easy to use .Net microformats parser

Reading parsed data with C#

The UfDataNode data structure provides a tree representation of the parsed microformts. Each node can have a collection of child in the "Nodes" property. You can easily recurs your way through the structure as demonstrated in the code below.

There are two additions methods provide by UfDataNode "DescendantValue" and "DescendantNode" these allow more direct access to node values. They take a very simple object/array description as a string.

Code example

using UfXtract;

string url = "http://www.glennjones.net/about/";

UfWebRequest webRequest = new UfWebRequest();
webRequest.Load(url, UfFormats.HCard());

UfDataNode hcard = webRequest.Data.Nodes[0];
string gn1 = hcard.DescendantValue("n/given-name");
string gn2 = hcard.DescendantNode("n/given-name").Value;
string ea = hcard.DescendantNode("adr[0]/extended-address[1]").Value;

Response.Write("<div>" + gn1 + "</div>");
Response.Write("<div>" + gn2 + "</div>");
Response.Write("<div>" + ea + "</div>");

Response.Write("<html><body>");
foreach (UfDataNode node in webRequest.Data.Nodes)
    WriteNode(node, "");

Response.Write("</body></html>");


public void WriteNode(UfDataNode node, string indent)
{
    Response.Write("<div>" + indent + node.Name + " - " + node.Value);
    indent += "&nbsp;&nbsp;&nbsp;";
    foreach (UfDataNode childnode in node.Nodes)
        WriteNode(childnode, indent);
}
Download Code MIT Open Source License About the UfXtract .Net library

Output formats

Formats

Inputs

.Net

Reporting and errors