How to use the xml2js.processors.stripPrefix function in xml2js

To help you get started, we’ve selected a few xml2js 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 Lattice-Automation / seqviz / src / io / parsers / jbei.js View on Github external
new Promise((resolve, reject) => {
    // util reject function that will be triggered if any fields fail
    const rejectJBEI = errType =>
      reject(new Error(`Failed on JBEI file; ${errType}`));

    // weird edge case with directed quotation characters
    const fileString = JBEI.replace(/“|”/g, '"');

    xml2js.parseString(
      fileString,
      {
        xmlns: true,
        attrkey: "xml_tag",
        tagNameProcessors: [processors.stripPrefix]
      },
      (err, parsedJBEI) => {
        if (err) rejectJBEI(err);

        // destructure the paramaeters from JBEI
        const { seq } = parsedJBEI;
        const { name, sequence, features, circular } = seq;

        // attempt to get the name out of the JBEI
        let parsedName = "Unnamed";
        if (name && name[0] && name[0]._) {
          parsedName = name[0]._;
        }

        // attempt to get the sequence. fail if it's not findable
        let parsedSeq = "";
github Lattice-Automation / seqviz / src / io / parsers / sbol.v2.js View on Github external
new Promise((resolve, reject) => {
    // util reject function that will be triggered if any fields fail
    const rejectSBOL = errType =>
      reject(new Error(`Failed on SBOLv2 file: ${errType}`));

    // weird edge case with directed quotation characters
    const fileString = sbol.replace(/“|”/g, '"');

    xml2js.parseString(
      fileString,
      {
        xmlns: true,
        attrkey: "xml_tag",
        tagNameProcessors: [processors.stripPrefix]
      },
      (err, parsedSBOL) => {
        if (err) {
          rejectSBOL(err);
        }

        let RDF = null;
        if (parsedSBOL.RDF) {
          ({ RDF } = parsedSBOL);
        }

        if (!RDF) {
          reject(new Error("No root RDF document"));
        }

        // check if anything is defined, return if not
github CumberlandGroup / node-ews / bin / ews.js View on Github external
client[ewsFunction](ewsArgs, function(err, result, body) {
            if(err) {
              cb(err);
            } else {
              // parse body xml
              parseString(body, {
                tagNameProcessors: [processors.stripPrefix],
                attrNameProcessors: [processors.stripPrefix],
                valueProcessors: [processors.stripPrefix],
                attrValueProcessors: [processors.stripPrefix]
              }, function(err, result){
                if(err) {
                  cb(err, null);
                } else {
                  cb(err, result);
                }
              });
            }
          });
github Lattice-Automation / seqviz / src / io / parsers / sbol.v1.js View on Github external
reject(new Error("Took to long to parse SBOL"));
    }, 2000);

    // util reject function that will be triggered if any fields fail
    const rejectSBOL = errType =>
      reject(new Error(`Failed on SBOL file; ${errType}`));

    // weird edge case with directed quotation characters
    const fileString = sbol.replace(/“|”/g, '"');

    xml2js.parseString(
      fileString,
      {
        xmlns: true,
        attrkey: "xml_tag",
        tagNameProcessors: [processors.stripPrefix]
      },
      (err, parsedSBOL) => {
        if (err) rejectSBOL(err);
        let RDF = null;
        if (parsedSBOL.RDF) ({ RDF } = parsedSBOL);
        if (!RDF) reject(new Error("No root RDF document"));

        const { Collection, DnaComponent } = RDF;
        if (Collection && Collection.length) {
          // it's a collection of DnaComponents, parse each to a part
          const partList = [];
          Collection.forEach(({ component }) => {
            if (component && component.length) {
              component.forEach(({ DnaComponent: nestedDnaComponent }) => {
                partList.push(
                  dnaComponentToPart(nestedDnaComponent[0], {
github Evinyatar / pith / plugins / upnp-mediaserver / services / Service.js View on Github external
        let parsedData = await async.wrap(cb => new Parser({tagNameProcessors: [processors.stripPrefix]}).parseString(data, cb));
        return await this.actionHandler(action, parsedData['Envelope']['Body'][0][action][0]);