我正在使用 nodejs 将对象转换为 xml。我想<!-- My personal comment -->
在 xml 中添加注释。我试过这段代码,但createComment
总是未定义。
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);