Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.84k stars 596 forks source link

this.removeAllListeners is not a function #697

Closed devmanzur closed 9 months ago

devmanzur commented 9 months ago

image

image

here is my function

async function parseXML(xmlContent: string): Promise<{ [key: string]: string }[]> {
  const parser = new xml2js.Parser({ explicitArray: true });
  const parsedData = await parser.parseStringPromise(xmlContent);

  const rowData = parsedData.DATAPACKET.ROWDATA[0].ROW;
  const rowsKeyValue: { [key: string]: string }[] = [];

  rowData.forEach((row: any) => {
    if (row != undefined) {
      const attributes: { [key: string]: string } = {};
      for (const key in row.$) {
        attributes[key] = row.$[key];
      }
      rowsKeyValue.push(attributes);
    }
  });

  return rowsKeyValue;
}
jasonhutton-sd commented 7 months ago

What was the fix?

mamay12 commented 6 months ago

@devmanzur @jasonhutton-sd Any updates? I got this error too and a little confused

kontinuity commented 6 months ago

Solution is here:

https://github.com/Leonidas-from-XIV/node-xml2js/issues/88#issuecomment-1836659197

pdowling-udrew commented 5 months ago

If it helps, this error appeared after I upgraded my project from vite 3.2.7 to vite 5.0.2.

npm i events as per @kontinuity 's link solved it.

jackytank commented 2 months ago

If it helps, this error appeared after I upgraded my project from vite 3.2.7 to vite 5.0.2.

npm i events as per @kontinuity 's link solved it.

thats worked for me, tks