import * as xml2js from "xml2js" ; export function stringifyXML ( obj , opts ? ) { const builder = new xml2js . Builder ( { rootName : ( opts || { } ) . rootName , renderOpts : { pretty : false , } , } ) ; return builder . buildObject ( obj ) ; } export function parseXML ( str ) { const xmlParser = new xml2js . Parser ( { explicitArray : false , explicitCharkey : false , explicitRoot : false , } ) ; return new Promise ( ( resolve , reject ) => { if ( ! str ) { reject ( new Error ( "Document is empty" ) ) ; } else { xmlParser . parseString ( str , ( err ? , res ? ) => { if ( err ) { reject ( err ) ; } else { resolve ( res ) ; } } ) ; } } ) ; }