How to use xmldoc - 10 common examples

To help you get started, we’ve selected a few xmldoc 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 stadline / svg-flatten / test / flatten.spec.js View on Github external
it('should flatten path groups', function() {
        var source = new xmldoc.XmlDocument('<svg><g><path d="M300,200 350,250"></path><path d="M400,200 450,250"></path></g></svg>');
        var target = new xmldoc.XmlDocument('<svg><path d="M300,200 350,250 M400,200 450,250"></path></svg>');

        // test
        expect(flattenFn(source).toString()).to.be.equal(target.toString());
    });
github fedspendingtransparency / data-act-broker-web-app / src / js / components / SharedComponents / icons / iconSingleton.js View on Github external
parseSvg(rawSvg) {
        // downloaded raw SVG data, send it through an XML parser
        const data = new xmldoc.XmlDocument(rawSvg);

        // iterate through each symbol and extract the symbol's content XML as a string and also its viewbox attribute
        data.childrenNamed('symbol').forEach((symbol) => {
            let childData = '';
            symbol.eachChild((child) => {
                childData += child.toString();
            });

            // save all this data into the svg data singleton
            this.svgCache[symbol.attr.id] = {
                data: childData,
                viewBox: symbol.attr.viewBox
            };
        });
    }
github s-KaiNet / node-sp-auth / src / utils / AdfsHelper.ts View on Github external
.then(xmlResponse => {
        let doc: any = new xmldoc.XmlDocument(xmlResponse);

        let tokenResponseCollection: any = doc.childNamed('s:Body').firstChild;
        if (tokenResponseCollection.name.indexOf('Fault') !== -1) {
          throw new Error(tokenResponseCollection.toString());
        }

        let responseNamespace: string = tokenResponseCollection.name.split(':')[0];
        let securityTokenResponse: any = doc.childNamed('s:Body').firstChild.firstChild;
        let samlAssertion: any = securityTokenResponse.childNamed(responseNamespace + ':RequestedSecurityToken').firstChild;
        let notBefore: string = samlAssertion.firstChild.attr['NotBefore'];
        let notAfter: string = samlAssertion.firstChild.attr['NotOnOrAfter'];

        return {
          value: samlAssertion.toString({ compressed: true }),
          notAfter: notAfter,
          notBefore: notBefore
github brave-experiments / brave-extension-store / src / updateExtension.js View on Github external
const getResponseComponents = (responseXML) => {
  const doc = new xmldoc.XmlDocument(responseXML)
  if (doc.attr.protocol !== '3.0') {
    console.error('Only protocol v3 is supproted')
    return undefined
  }
  const extensions = doc.childrenNamed('app')
    .map((app) => {
      const updatecheckManifest = app.descendantWithPath('updatecheck.manifest')
      const updatecheckManifestPackages = app.descendantWithPath('updatecheck.manifest.packages.package')

      return [
        app.attr.appid,
        updatecheckManifest && updatecheckManifest.attr.version,
        updatecheckManifestPackages && updatecheckManifestPackages.attr.hash_sha256
      ]
    })
  return extensions
github nfarina / homebridge / accessories / XfinityHome.js View on Github external
}, function(err, response, body) {

      if (!err && response.statusCode == 200) {

        var doc = new xmldoc.XmlDocument(body);
        that.loginToken = doc.valueWithPath("LoginToken");
        that.refreshLoginCookie();
      }
      else {
        that.log("Error '"+err+"' getting login token: " + body);
      }
    });
  },
github microsoft / azure-repos-vscode / src / clients / tfscatalogsoapclient.ts View on Github external
private parseOrganizationRootPath(envelopeXml: any): string {
        if (!envelopeXml) {
            throw new Error(`No SOAP envelope was received for OrganizationRoot from ${this.endpointUrl}`);
        }
        const organizationDocument: xmldoc.XmlDocument = new xmldoc.XmlDocument(envelopeXml);
        const soapBody: xmldoc.XmlElement = organizationDocument.childNamed(TfsCatalogSoapClient.XmlSoapBody);
        const nodesResponse: xmldoc.XmlElement = soapBody.childNamed(TfsCatalogSoapClient.XmlQueryNodesResponse);
        const nodesResult: xmldoc.XmlElement = nodesResponse.childNamed(TfsCatalogSoapClient.XmlQueryNodesResult);
        const catalogResources: any = nodesResult.childNamed(TfsCatalogSoapClient.XmlCatalogResources);
        if (!catalogResources) {
            throw new Error(`No CatalogResources were received for OrganizationRoot from ${this.endpointUrl}`);
        }
        //Spin through children doing insensitive check
        let orgRoot: any;
        for (let idx: number = 0; idx &lt; catalogResources.children.length; idx++) {
            if (catalogResources.children[idx].attr.ResourceTypeIdentifier.toLowerCase() === TfsCatalogSoapClient.OrganizationalRoot) {
                orgRoot = catalogResources.children[idx];
                break;
            }
        }
        if (!orgRoot) {
github MattNer0 / Epiphany / src / renderer / js / utils / opml.js View on Github external
parseFile(fileContent, outlineObj) {
		if (fileContent === '') return

		var doc = new xmldoc.XmlDocument(fileContent)
		var head = doc.descendantWithPath('head')

		var metadata = {
			createdAt: moment(head.valueWithPath('dateCreated')).format('YYYY-MM-DD HH:mm:ss'),
			updatedAt: moment(head.valueWithPath('dateModified')).format('YYYY-MM-DD HH:mm:ss')
		}

		outlineObj.title = head.valueWithPath('title')
		outlineObj.metadata = metadata

		outlineObj.nodes = doc.descendantWithPath('body').childrenNamed('outline').map(node => self.parse_nodes(node, outlineObj))
	},
github learningobjectsinc / mathml-to-asciimath / index.js View on Github external
function toAsciiMath(mathml) {
  var doc = new xmldoc.XmlDocument(mathml);

  var buffer = [];
  handle(doc, buffer);
  return buffer.join(' ');
}
github rnpm / rnpm / src / config / android.js View on Github external
const getPackageName = (src) => {
  const manifest = new xml.XmlDocument(
    fs.readFileSync(path.join(src, 'src/main/AndroidManifest.xml'), 'utf8')
  );

  return manifest.attr.package;
};

xmldoc

A lightweight XML Document class for JavaScript.

MIT
Latest version published 2 years ago

Package Health Score

73 / 100
Full package analysis

Popular xmldoc functions