I am converting an object to an xml with nodejs.
I want to add a comment <!-- My personal comment -->
to the xml. I tried this code but createComment
is always undefined.
const xml2js = require('xml2js');
const parser = new xml2js.Parser();
const builder = new xml2js.Builder();
const parser = new xml2js.Parser();
parser.parseString(body, (e, myobject) => {
myobject.test = "test";
const xml = builder.buildObject(myobject);
//NOT WORKING var c = builder.createComment("My personal comment");
//NOT WORKING var c = xml.createComment("My personal comments");
xml.appendChild(c);