How to use xmldom

Comprehensive xmldom code examples:

How to use xmldom.DOMImplementation:

6
7
8
9
10
11
12
13
14
15
16
17


const src = path.join(__dirname, '..', 'src')
const _svg = fs.readFileSync(path.join(src, 'welcome.svg'), 'utf-8')
const barcode = data => {
    const xmlSerializer = new XMLSerializer();
    const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null);
    const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg');


    JsBarcode(svgNode, data, {
        xmlDocument: document,

How to use xmldom.XMLSerializer:

5
6
7
8
9
10
11
12
13
14
15
16
const cp = require('child_process')


const src = path.join(__dirname, '..', 'src')
const _svg = fs.readFileSync(path.join(src, 'welcome.svg'), 'utf-8')
const barcode = data => {
    const xmlSerializer = new XMLSerializer();
    const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null);
    const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg');


    JsBarcode(svgNode, data, {

How to use xmldom.DOMParser:

359
360
361
362
363
364
365
366
367
368
  let dataBuffer = await result.kmz.arrayBuffer();
  const buffer = Buffer.from(dataBuffer);
  fs.writeFileSync(filename, buffer);
}else if(extname === '.geojson'){
  let result = await exportKmlOrKmz(false, entitys);
  const data = new DOMParser().parseFromString(result.kml);
  const geojsonStr = tj.kml(data);
  fs.writeFileSync(filename, JSON.stringify(geojsonStr));
}
resolve();