How to use the xml-js.js2xml function in xml-js

To help you get started, we’ve selected a few xml-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vmware / clarity / latest / prerender.ts View on Github external
const notFound = () => {
  // Copy index.html from not-found to 404.html
  copySync(join(BROWSER_FOLDER, 'not-found', 'index.html'), join(BROWSER_FOLDER, '404.html'));
  // Remove not-found from sitemap
  const sitemapFile = readFileSync(join(BROWSER_FOLDER, "sitemap.xml"), {encoding: 'utf8'});
  const sitemap = converter.xml2js(sitemapFile, {compact: true});
  sitemap.urlset.url = sitemap.urlset.url.filter(item => {
    if (item.loc._text.indexOf('/not-found') >= 0) {
      return false;
    }
    return true;
  });
  writeFileSync(join(BROWSER_FOLDER, "sitemap.xml"), converter.js2xml(sitemap, {compact: true, spaces: 4}), {encoding: 'utf8'});
  // Delete the not-found directory
  del.sync([`${BROWSER_FOLDER}/not-found/**`]);
};
github shroudedcode / apk-mitm / src / tasks / modify-netsec-config.ts View on Github external
)
  const config = fileXml['network-security-config'][0]

  // Remove certificate pinning rules
  // See https://developer.android.com/training/articles/security-config#pin-set
  delete config['pin-set']

  const overrides = (config['debug-overrides'] || (config['debug-overrides'] = [{}]))[0]
  const trustAnchors = (overrides['trust-anchors'] || (overrides['trust-anchors'] = [{}]))[0]
  const certificates = trustAnchors['certificates'] || (trustAnchors['certificates'] = [])

  if (!certificates.filter((c: any) => c._attributes.src === 'user').length) {
    certificates.push({ _attributes: { src: 'user' } })
  }

  await fs.writeFile(path, xml.js2xml(fileXml, { compact: true, spaces: 4 }))
}
github idleberg / atomizr-cli / lib / converter / sublime.js View on Github external
obj = {
            // _comment: ' ' + this.meta + ' ',
            snippet: {
                content: {
                    _cdata: input.completions[0].contents
                },
                tabTrigger: {
                    _text: input.completions[0].trigger
                },
                scope: {
                    _text: input.scope
                }
            }
        };
    }
    output = xml_js_1.js2xml(obj, {
        compact: true,
        spaces: 4
    });
    return output;
};
exports.writeXml = writeXml;
github Hackzzila / krypton / build.js View on Github external
elements: [{
          type: 'text',
          text: `${arch === 'x64' ? 'x64' : 'x86'}-windows-static`,
        }],
      });

      globals.elements.push({
        type: 'element',
        name: 'VcpkgEnabled',
        elements: [{
          type: 'text',
          text: 'true',
        }],
      });

      fs.writeFileSync(path.resolve('build', 'krypton.vcxproj'), xml.js2xml(vcxproj, { spaces: 2 }));

      execSync(`${path.resolve('node_modules', '.bin', 'node-gyp')} build --target=v${target} --arch=${arch}`, {
        stdio: 'inherit',
        env: {
          ...process.env,
          ...env[arch],
        },
      });

      fs.copyFileSync(path.resolve('build', 'Release', 'krypton.node'), path.resolve('builds', `${process.platform}-${arch}-${id}.node`));
    }
  }
}
github videomanagertools / scraper / src / renderer / utils / xml.ts View on Github external
export const js2xml = data => xmljs.js2xml(data, { compact: true, spaces: 4 });
export const xml2js = xml => xmljs.xml2js(xml, { compact: true });
github vmware / clarity / src / website / generate-news.js View on Github external
item.replace(/src\/website\/src\/releases\/(.*?)\/(.*?)\.html/i, '$2')
  );

  releases.forEach(release => {
    urls.push({
      loc: {
        _text: baseUrl + release,
      },
      changefreq: {
        _text: 'daily',
      },
    });
  });
  sitemap.urlset.url = urls;

  fs.writeFileSync(sitemapPath, converter.js2xml(sitemap, { compact: true, spaces: 4 }), { encoding: 'utf8' });
}
github lantanagroup / FHIR.js / convertToJs.ts View on Github external
case 'integer':
                case 'unsignedInt':
                case 'positiveInt':
                    addExtra(value, index);

                    if (value.attributes['value']) {
                        if (obj[property._name] instanceof Array) {
                            obj[property._name].push(toNumber(value.attributes['value']))
                        } else {
                            obj[property._name] = toNumber(value.attributes['value'])
                        }
                    }
                    break;
                case 'xhtml':
                    if (value.elements && value.elements.length > 0) {
                        const div = convert.js2xml({elements: [XmlHelper.escapeInvalidCharacters(value)]});
                        if (obj[property._name] instanceof Array) {
                            obj[property._name].push(div);
                        } else {
                            obj[property._name] = div;
                        }
                    }
                    break;
                case 'Element':
                case 'BackboneElement':
                    const newValue = {};

                    for (let x in property._properties) {
                        const nextProperty = property._properties[x];
                        this.propertyToJS(value, newValue, nextProperty, surroundDecimalsWith);
                    }
github balena-os / jetson-flash / lib / resin-jetson-flash.js View on Github external
return new Bluebird((resolve, reject) => {
			const read = str(
				convert.js2xml(result, {
					spaces: 4,
				}),
			);

			read.pipe(stream);

			read.on('end', () => {
				resolve(options.output);
			});
			read.on('error', reject);
		});
	}
github lantanagroup / FHIR.js / convertToXml.js View on Github external
ConvertToXml.prototype.convert = function (obj) {
        if (obj.hasOwnProperty('resourceType')) {
            var xmlObj = this.resourceToXML(obj);
            return convert.js2xml(xmlObj);
        }
    };
    ConvertToXml.prototype.resourceToXML = function (obj, xmlObj) {

xml-js

A convertor between XML text and Javascript object / JSON text.

MIT
Latest version published 6 years ago

Package Health Score

65 / 100
Full package analysis