I like your xml-writer, in npm you can see another dependancy. I use your module to generate dozens of small XMLs in a second. I construct lots of XMLWriter objects.
Each time XML writer is created, constructor init all the methods. We can remove initing methods in constructor by using XmlWriter.prototype. Prototype is fully initialized in the first require, while constructor is called million times a day. I know it breaks the clouse, but I think it should not be a problem as you use this.something and this is properly inited in prototype methods
I propose changing
this.startElement = function(name) {
...
with
XMLWriter.prototype.startElement = function(name) {
...
So instead of the single constructor function with all the job there we will have a lightweight constructor plus a prototype that is shared among millions of XMLWriter instances