Ufxtract

Powerful, easy to use .Net microformats parser

Creating format definitions

The parser run off format definition objects. These objects describe the structure of the microformat and the rules to parse it. They are constructed of three object types "UfFormatDescriber", "UfElementDescriber" and "UfAttributeValueDescriber". It worth noting that there are a few generalist rules applied by the parse which are not in definition objects.

You can create your own format definition objects to add new microformat or POSH patterns to UfXtract.

Format describer for the n(name) elemant of hCard microformt

public static UfFormatDescriber Name()
{
    UfFormatDescriber uFormat = new UfFormatDescriber();
    uFormat.Name = "n";
    uFormat.Description = "Name";
    uFormat.Type = UfFormatDescriber.FormatTypes.Compound;
    uFormat.BaseElement = new UfElementDescriber("n", false, false, UfElementDescriber.PropertyTypes.None);
    uFormat.BaseElement.Elements.Add(new UfElementDescriber("type", false, true, "intl,postal,parcel,work,dom,home,pref"));
    uFormat.BaseElement.Elements.Add(new UfElementDescriber("honorific-prefix", false, true, UfElementDescriber.PropertyTypes.Text));
    uFormat.BaseElement.Elements.Add(new UfElementDescriber("given-name", false, true, UfElementDescriber.PropertyTypes.Text));
    uFormat.BaseElement.Elements.Add(new UfElementDescriber("additional-name", false, true, UfElementDescriber.PropertyTypes.Text));
    uFormat.BaseElement.Elements.Add(new UfElementDescriber("family-name", false, true, UfElementDescriber.PropertyTypes.Text));
    uFormat.BaseElement.Elements.Add(new UfElementDescriber("honorific-suffix", false, true, UfElementDescriber.PropertyTypes.Text));
    return uFormat;
}

Format describer for rel=tag microformt

public static UfFormatDescriber Tag()
{
    UfFormatDescriber uFormat = new UfFormatDescriber();
    uFormat.Name = "tag";
    uFormat.Description = "Tag";
    uFormat.Type = UfFormatDescriber.FormatTypes.Elemental;

    UfElementDescriber uFElement = new UfElementDescriber();
    uFElement.Name = "tag";
    uFElement.Multiples = true;
    uFElement.AllowedTags.Add("a");
    uFElement.AllowedTags.Add("link");
    uFElement.Attribute = "rel";
    uFElement.Type = UfElementDescriber.PropertyTypes.UrlTextTag;
    uFormat.BaseElement = uFElement;
    uFElement.AttributeValues.Add(new UfAttributeValueDescriber("tag"));
    return uFormat;
}
Download Code MIT Open Source License About the UfXtract .Net library

Output formats

Formats

Inputs

.Net

Reporting and errors