Open JoseAnt86 opened 4 years ago
I don't think there isn't any yet but if you want you can achieve this using tagNameProcessors
const parser = new xml2js.Parser({
tagNameProcessors: [(tag) => `${prefix}:${tag}`],
});
await parser.parseStringPromise(xmlString);
When going from XML to JS, the "processors.stripPrefix" allows you to remove the prefix. Is it possible for the Builder to have an option for addPrefix?
const jsonObj = { foo: { bar: { hello: 'world' } } }; const builder = new xml2js.Builder({addPrefix: 'n1'}); const xml = builder.buildObject(jsonObj); console.log(xml);