How to use the ltx/lib/parsers/ltx.js function in ltx

To help you get started, we’ve selected a few ltx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-xml2json / src / xml2json.js View on Github external
Xml2Json.prototype._prepareParser = function (callback) {

    const self = this;
    const parser = new ltxParser();

    let c =0;
    parser.on("startElement", function (name, attrs) {
        const tag_ns = resolve_namespace(name);
        self.current_state._on_startElement(tag_ns.tag, attrs);
        //xxxconsole.log("name  ",name,tag_ns.tag);
        c+=1;
    });
    parser.on("endElement", function (name) {
        const tag_ns = resolve_namespace(name);
        self.current_state._on_endElement(tag_ns.tag);
        c-=1;
        if (c ==0) {
          parser.emit("close");
        }
    });
github node-opcua / node-opcua / packages / node-opcua-xml2json / source / xml2json.ts View on Github external
private _prepareParser(callback: (err?: Error) => void): LtxParser {

        const parser = new LtxParser();
        let c = 0;
        parser.on("startElement", (name: string, attrs: XmlAttributes) => {
            const tag_ns = resolve_namespace(name);
            this.current_state._on_startElement(tag_ns.tag, attrs);
            c += 1;
        });
        parser.on("endElement", (name: string) => {
            const tag_ns = resolve_namespace(name);
            this.current_state._on_endElement(tag_ns.tag);
            c -= 1;
            if (c === 0) {
                parser.emit("close");
            }
        });
        parser.on("text", (text: string) => {
            text = text.trim();