Kiwi Document C# API

To parse a document, simply pass the raw text into the constructor.

var doc = new KiwiDocument("the entire text of the document");

The document will parse, and populate all its properties.

Section Collections

The primary feature of the document are lists of Section objects, in several collections:

There are methods for working with sections:

Sections

Metadata Collections

Each section – and the document as a whole – has a MetaCollection object exposed at the Meta property. It exposes the following methods:

Document Meta

The document as a whole – like each of its sections – exposes a Meta property which functions as above. This meta collection is simply the same meta collection of the first section.

However, the document also exposes an AllMeta property which is a consolidated list of all the meta items from all the sections in the document.

Many of the meta-related methods return the first meta value found for the key, which means AllMeta can be used to search down through multiple sections for a specific meta key.

Meta also has a few convenience properties for common meta.

Example

Consider this document:

title: The Barker Family
established: 1999-06-05

[[ person ]]
first: Deane
last: Barker

The husband

[[ person ]]
first: Annie
last: Barker

The wife

We can work with it like this:

var doc = new KiwiDocument(documentText);

Console.WriteLine(doc.Title);
Console.WriteLine($"Est. {doc.Get<DateTime>("established"):MMMM, d yyyy}");

foreach(var section in doc.GetSections("person"))
{
    var lastName = section.Meta.Get("last");
    var firstName = section.Meta.Get("first")
    Console.WriteLine($"{last}, {first}: {section.Content}");
}

Resulting in:

The Barker Family
Est. June 5, 1999
Barker, Deane: The husband
Barker, Annie: The wife

SectionMap

Each section has a Map property which exposes numerous properties regarding where that section lies in context of the entire document.

This is item #1 in a sequence of 4 items.

You can use your left/right arrow keys to navigate