Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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");
}
});
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();