I am using "xmlbuilder" node.js module to create xml file. I need to create a CDATA section as follows:
<notestext><![CDATA[{Notes Text}]]></notestext>
I referred the github link, but didn't found any useful stuff.
How to create such CDATA section in an xml file using "xmlbuilder" node.js module?
let builder = require('xmlbuilder', { encoding: 'utf-8' });
let xml = builder.create('Slides');
xml.ele("notestext","<![CDATA[" + element.notes_text + "]]>");
xml.end({ pretty: true });
console.log(xml.toString());
From Doc you posted
CDATA Nodes CDATA nodes are created with the cdata function (can also be abbreviated to dat or d). The value should not include CDATA delimiters
ele.dat('this will be surrounded by CDATA delimiters');
var builder = require('xmlbuilder', { encoding: 'utf-8' });
var xml = builder.create('slides');
xml.ele('notestext').dat('{Notes Text}');
xml.end({
pretty: true,
indent: ' '
});
console.log(xml.toString());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With