Open btsimonh opened 2 years ago
@oozcitak also for me, this method not work like as docs
my workaround was to replace the output function in xml2js, ending:
let xmlbuilderoptions = {
pretty: defaultPretty,
indent: " ",
newline: defaultNewline,
writer: { element: newElement /*endline: newEndline*/ },
//async: false,
};
let writer = xmlbuilder.stringWriter(xmlbuilderoptions);
let doc = render(rootElement, rootObj);
return doc.end(writer);
basically - passing in a created stringWriter into which the options were inserted at creation, rather than passing the options into doc.end().
please update the documentation :(
it's really hard to understand how to use a custom writer right now
this line is not specified:
let writer = xmlbuilder.stringWriter(xmlbuilderoptions);
I just discovered what seems to be the issue - "pretty" has changed to "prettyPrint".
So ele.end({ prettyPrint: true }) works!
Thanks to IntelliJ's pop-up documentation with links for leading me to that!
using xmlbuilder via xml2js, this file: https://github.com/Leonidas-from-XIV/node-xml2js/blob/master/src/builder.coffee calls end with writer options.
In previous versions, writer options could look like:
but the current version (and from version 11?) discards the 'writer' part of the options in 'filterOptions' (in XMLWriterBase).
the wiki: https://github.com/oozcitak/xmlbuilder-js/wiki still states the functions can be overridden.
Is there a way to override these functions?
br, Simon