(path: string)
| 2 | import xml2js from 'xml2js'; |
| 3 | |
| 4 | export async function readXML(path: string): Promise<any> { |
| 5 | try { |
| 6 | const xmlStr = await readFile(path, { encoding: 'utf-8' }); |
| 7 | try { |
| 8 | return await xml2js.parseStringPromise(xmlStr); |
| 9 | } catch (e: any) { |
| 10 | throw `Error parsing: ${path}, ${e.stack ?? e}`; |
| 11 | } |
| 12 | } catch (e) { |
| 13 | throw `Unable to read: ${path}`; |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | export function parseXML(xmlStr: string, options?: xml2js.OptionsV2): any { |
| 18 | const parser = options !== undefined ? new xml2js.Parser({ ...options }) : new xml2js.Parser(); |
no test coverage detected