-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
Build a small, composable, functional wrapper around xml-tokenizer to extract structured data from XML streams.
Why
- Improve DX over XPath/XQuery
- Avoid full-document parsing (streaming FTW)
- Encourage functional, testable, and extensible extractors
Example
const Book = extractObject({
category: attrAt(['book'], 'category'),
title: textAt(['book', 'title']),
lang: attrAt(['book', 'title'], 'lang'),
author: textAt(['book', 'author']),
year: textAt(['book', 'year']),
price: pipe(textAt(['book', 'price']), map(Number))
});
runExtractor(xml, pipe(
matchPath(['bookstore', 'book']),
matchAttrs({ category: 'COOKING' }),
collect(Book),
forEach(console.log)
));