Documentation / @facturometro/parser / parse
Function: parse() ​
parse(
xml):ParseResult<UncheckedDocument>
Defined in: parse.ts:154
Parses a UBL invoice or credit note, whichever the document element says it is.
Parameters ​
xml ​
string
The document, as text.
Returns ​
ParseResult<UncheckedDocument>
The model, the structural diagnostics and whether any of them is fatal.
Throws ​
When the document is not well-formed XML.
Throws ​
When the document element is neither a UBL Invoice nor a UBL CreditNote.
Example ​
ts
import { parse } from '@facturometro/parser';
const { document, ok } = parse(xml);
if (document.kind === 'Invoice') console.log(document.invoiceLine?.length);