For AI agents: the complete documentation index is available at /pds2img/llms.txt, the full documentation bundle is available at /pds2img/llms-full.txt, and this page is available as Markdown at /pds2img/api/parsers.md.

Parsers

parseLBL

function parseLBL(buffer: ArrayBuffer | ArrayBufferView): PDSLabel;

Parses a PDS3 label into a PDSLabel. It accepts the bytes of a .LBL file, or of an .IMG file with an attached label. Parsing stops at END.

const label = parseLBL(lblBuffer);

label.RECORD_BYTES; // 1024
label['^IMAGE']; // ['C3592903_RAW.IMG', 4]
label.IMAGE; // { LINES: 800, LINE_SAMPLES: 800, LINE_PREFIX_BYTES: 224, ... }
label.EXPOSURE_DURATION; // { value: 1.44, unit: 'SECOND' }

OBJECT and GROUP blocks become nested objects keyed by their name. If several blocks share a name (for example, several COLUMN objects), the last one wins.

See Supported formats for how each kind of value is parsed.

parseXML

function parseXML(xmlText: string): Promise<Document>;

Parses a PDS4 label. It uses the global DOMParser when available (browsers, happy-dom, jsdom). Otherwise it loads @xmldom/xmldom on demand.

const xml = await parseXML(xmlText);
xml.getElementsByTagName('target_name').item(0)?.textContent; // e.g. 'Mars'
Tip

Use getElementsByTagName instead of querySelector with PDS4 documents. Some DOM implementations do not reliably match element names that contain underscores, such as Array_2D_Image.