-
Notifications
You must be signed in to change notification settings - Fork 5
XMLStreamPrinter
do- edited this page Feb 21, 2026
·
11 revisions
XMLStreamPrinter is a stream mode XML generator.
const fs = require ('node:fs')
out = fs.createWriteStream ('out.xml')
const {XMLStreamPrinter} = require ('xml-toolkit')
const xp = new XMLStreamPrinter ({
// out,
// decl: {encoding: 'UTF-8', standalone: 1},
// space: 2,
// attrSpace: 1,
// EOL: '\n',
// level: 0,
// encodeLineBreaks: false,
})
xp
.openElement ('outer')
.writeAttribute ('id', '1')
.openElement ('inner')
.writeCharacters ('txt')
.closeElement ()
.openElement ('leaf').closeElement ()
.closeElement ()
out.end ()The API is almost the same as XMLPrinter's (see there for details).