Socket
Book a DemoInstallSign in
Socket

@iebh/cacx

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iebh/cacx

Intentionally simple XML parser designed for minimal dependency and speed

1.0.3
latest
npmnpm
Version published
Maintainers
4
Created
Source

@IEBH/CACX

Intentionally simple XML parser designed for minimal dependency and speed.

API

new CacxParser(options)

Initalize the parser with options.

import Parser from '@iebh/cacx';
// OR
import {CacxParser} from '@iebh/cacx';

let parser = new Parser()
    .append('<a><b><c>Hello World</c></b></a>')
    .exec()
    .value() //= `{tag: 'a', children: ...}`

CacxParser.append(input)

Append (or set) string content to be parsed. Returns the CacxParser instance.

CacxParser.exec()

Parse the existing buffer into XML. Can be called after each append() to drain the buffer. This function should be called at least once prior to value(). Returns the CacxParser instance.

flatten()

Process the current stack into a logical do-the-right-thing data structure. See the various settings.flatten* options to configure the behaviour here. Returns the CacxParser instance.

CacxParser.value()

Returns the parsed XML stack. This will throw if settings.collect is falsy. Returns the nested object stack.

parse(input, options)

Simple all-in-one string parser helper.

import {parser} from '@iebh/cacx';

parse('<a><b><c>Hello World</c></b></a>') //= `{tag: 'a', children: ...}`

parseFile(path, options)

Helper for streaming file inputs into the parser.

import {parseFile} from '@iebh/cacx';

parseFile('./file.xml') //= `{tag: 'a', children: ...}`

parseCollectionFile(path, tags, options)

Helper to stream a file and run a callback when a named tag closes.

import {parseCollectionFile} from '@iebh/cacx';

parseCollectionFile(
    './file.xml',
    {
        record(node) {
            // Node should represent the state of any `record` element within the XML
        },
    },
    { // Other options
        flatten: true, // Try to flatten the output into a logical JavaScript object
    },
);

Keywords

xml

FAQs

Package last updated on 26 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.