Skip to content

Documentation / @einvoice-ts/parser / parseInvoice

Function: parseInvoice() ​

parseInvoice(xml): ParseResult<UncheckedInvoice>

Defined in: parse.ts:214

Parses a UBL invoice.

Parameters ​

xml ​

string

The document, as text.

Returns ​

ParseResult<UncheckedInvoice>

The model, the structural diagnostics and whether any of them is fatal.

Throws ​

When the document is not well-formed XML, or its elements nest deeper than 1,000 levels (the document element is the first).

Throws ​

When the document element is neither a UBL Invoice nor a UBL CreditNote.

Throws ​

When the document is a credit note.

Example ​

ts
import { parseInvoice } from '@einvoice-ts/parser';

const { diagnostics, document } = parseInvoice(xml);
document.id; // string | undefined

MIT licensed. Specification material belongs to OpenPeppol, CEN and OASIS (see NOTICE). Peppol is a trademark of OpenPeppol AISBL; this project is not affiliated with it.