How to use the xpath.js function in xpath

To help you get started, we’ve selected a few xpath 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 natergj / excel4node / tests / lib / xml_test_doc.js View on Github external
this.select = function (path) {
        var nodes = select(doc, path);
        return nodes.map(function (n) {
            return n.toString();
        });
    };
github stefanw / vbb-json / lib / vbb.js View on Github external
for (var k = 0; k < stops.length; k += 1) {
        journey.push(parseBasicStop(stops[k], date));
      }
      secJson.push({
        departure: {
          name: select(section, ".//Departure//Station/@name")[0].value,
          id: select(section, ".//Departure//Station/@externalId")[0].value,
          lat: convertCoord(select(section, ".//Departure//Station/@y")[0].value),
          lng: convertCoord(select(section, ".//Departure//Station/@x")[0].value),
          time: makeTimestamp(date, select(section, ".//Departure//Dep/Time/text()")[0].data),
          platform: strip(getData(select(section, ".//Departure//Dep/Platform/Text/text()")[0]))
        },
        arrival: {
          name: select(section, ".//Arrival//Station/@name")[0].value,
          id: select(section, ".//Arrival//Station/@externalId")[0].value,
          lat: convertCoord(select(section, ".//Arrival//Station/@y")[0].value),
          lng: convertCoord(select(section, ".//Arrival//Station/@x")[0].value),
          time: makeTimestamp(date, select(section, ".//Arrival//Arr/Time/text()")[0].data),
          platform: strip(getData(select(section, ".//Arrival//Arr/Platform/Text/text()")[0]))
        },
        journey: journey,
        transport: {
          name: strip(select(section, ".//Journey//Attribute[@type='NAME']//Text/text()")[0].data),
          direction: strip(select(section, ".//Journey//Attribute[@type='DIRECTION']//Text/text()")[0].data)
        }
      });
    }
    conJson.push({
      sections: secJson
    });
  }
  return conJson;
github stefanw / vbb-json / lib / vbb.js View on Github external
var parseBasicStop = function(stop, date) {
  station = select(stop, ".//Station");
  if (station.length) {
    var arrival = null, arrivalPlatform = null;
    var departure = null, departurePlatform = null;
    if (select(stop, ".//Arr").length) {
      arrival = makeTimestamp(date, select(stop, ".//Arr/Time/text()")[0].data);
      arrivalPlatform = strip(getData(select(stop, ".//Arr/Platform/Text/text()")[0]));
    }
    if (select(stop, ".//Dep").length) {
      departure = makeTimestamp(date, select(stop, ".//Dep/Time/text()")[0].data);
      departurePlatform = strip(getData(select(stop, ".//Dep/Platform/Text/text()")[0]));
    }
    return {
      name: select(stop, ".//Station/@name")[0].value,
      id: select(stop, ".//Station/@externalId")[0].value,
      lat: convertCoord(select(stop, ".//Station/@y")[0].value),
      lng: convertCoord(select(stop, ".//Station/@x")[0].value),
      arrival: arrival,
      arrivalPlatform: arrivalPlatform,
      departure: departure,
      departurePlatform: departurePlatform
    };
  }
};
github stefanw / vbb-json / lib / vbb.js View on Github external
station = select(stop, ".//Station");
  if (station.length) {
    var arrival = null, arrivalPlatform = null;
    var departure = null, departurePlatform = null;
    if (select(stop, ".//Arr").length) {
      arrival = makeTimestamp(date, select(stop, ".//Arr/Time/text()")[0].data);
      arrivalPlatform = strip(getData(select(stop, ".//Arr/Platform/Text/text()")[0]));
    }
    if (select(stop, ".//Dep").length) {
      departure = makeTimestamp(date, select(stop, ".//Dep/Time/text()")[0].data);
      departurePlatform = strip(getData(select(stop, ".//Dep/Platform/Text/text()")[0]));
    }
    return {
      name: select(stop, ".//Station/@name")[0].value,
      id: select(stop, ".//Station/@externalId")[0].value,
      lat: convertCoord(select(stop, ".//Station/@y")[0].value),
      lng: convertCoord(select(stop, ".//Station/@x")[0].value),
      arrival: arrival,
      arrivalPlatform: arrivalPlatform,
      departure: departure,
      departurePlatform: departurePlatform
    };
  }
};
github stefanw / vbb-json / lib / vbb.js View on Github external
var parseBasicStop = function(stop, date) {
  station = select(stop, ".//Station");
  if (station.length) {
    var arrival = null, arrivalPlatform = null;
    var departure = null, departurePlatform = null;
    if (select(stop, ".//Arr").length) {
      arrival = makeTimestamp(date, select(stop, ".//Arr/Time/text()")[0].data);
      arrivalPlatform = strip(getData(select(stop, ".//Arr/Platform/Text/text()")[0]));
    }
    if (select(stop, ".//Dep").length) {
      departure = makeTimestamp(date, select(stop, ".//Dep/Time/text()")[0].data);
      departurePlatform = strip(getData(select(stop, ".//Dep/Platform/Text/text()")[0]));
    }
    return {
      name: select(stop, ".//Station/@name")[0].value,
      id: select(stop, ".//Station/@externalId")[0].value,
      lat: convertCoord(select(stop, ".//Station/@y")[0].value),
      lng: convertCoord(select(stop, ".//Station/@x")[0].value),
      arrival: arrival,
      arrivalPlatform: arrivalPlatform,
      departure: departure,
      departurePlatform: departurePlatform
    };
  }
};
github EngageSoftware / DNN-JavaScript-Libraries / utility / validate.js View on Github external
} else {
			const fileName = fileNames[0];
			const jsFiles = files.filter(file =>
				equalCaseInsensitive(fileName, path.basename(file.path))
			);
			if (jsFiles.length === 0) {
				validationMessages.push(
					`File in manifest "${fileName}" is not in package zip`
				);
			}
		}

		const resourcesFiles = files.filter(
			file => path.basename(file.path) === 'Resources.zip'
		);
		const resourcesFileNames = select(
			doc,
			'/dotnetnuke/packages/package/components/component/resourceFiles/resourceFile/name/text()'
		).map(({ data }) => data);
		if (resourcesFiles.length < resourcesFileNames.length) {
			validationMessages.push(
				`"${
					resourcesFileNames[0]
				}" specified in manifest but is not in package zip`
			);
		} else if (resourcesFiles.length > resourcesFileNames.length) {
			validationMessages.push(
				`"${resourcesFiles[0].path}" is in package zip but is not specified in manifest`
			);
		}

		return validationMessages;
github stefanw / vbb-json / lib / vbb.js View on Github external
var parseTripRequestBody = function(body) {
  var doc = new dom().parseFromString(body);
  var connections = select(doc, "//Connection");
  var conJson = [];
  for (var i = 0; i < connections.length; i += 1) {
    var date = select(connections[i], './/Overview/Date/text()')[0].data;
    var sections = select(connections[i], './/ConSection');
    var secJson = [];
    for (var j = 0; j < sections.length; j += 1) {
      var section = sections[j];
      var journey = [];
      var stops = select(section, './/Journey/PassList/BasicStop');
      for (var k = 0; k < stops.length; k += 1) {
        journey.push(parseBasicStop(stops[k], date));
      }
      secJson.push({
        departure: {
          name: select(section, ".//Departure//Station/@name")[0].value,
          id: select(section, ".//Departure//Station/@externalId")[0].value,
          lat: convertCoord(select(section, ".//Departure//Station/@y")[0].value),
          lng: convertCoord(select(section, ".//Departure//Station/@x")[0].value),
          time: makeTimestamp(date, select(section, ".//Departure//Dep/Time/text()")[0].data),
github rapid7 / awsaml / api / routes / configure.js View on Github external
const safeXpath = (doc, p) => {
          try {
            return xpath(doc, p);
          } catch (_) {
            return null;
          }
        };
github stefanw / vbb-json / lib / vbb.js View on Github external
var sections = select(connections[i], './/ConSection');
    var secJson = [];
    for (var j = 0; j < sections.length; j += 1) {
      var section = sections[j];
      var journey = [];
      var stops = select(section, './/Journey/PassList/BasicStop');
      for (var k = 0; k < stops.length; k += 1) {
        journey.push(parseBasicStop(stops[k], date));
      }
      secJson.push({
        departure: {
          name: select(section, ".//Departure//Station/@name")[0].value,
          id: select(section, ".//Departure//Station/@externalId")[0].value,
          lat: convertCoord(select(section, ".//Departure//Station/@y")[0].value),
          lng: convertCoord(select(section, ".//Departure//Station/@x")[0].value),
          time: makeTimestamp(date, select(section, ".//Departure//Dep/Time/text()")[0].data),
          platform: strip(getData(select(section, ".//Departure//Dep/Platform/Text/text()")[0]))
        },
        arrival: {
          name: select(section, ".//Arrival//Station/@name")[0].value,
          id: select(section, ".//Arrival//Station/@externalId")[0].value,
          lat: convertCoord(select(section, ".//Arrival//Station/@y")[0].value),
          lng: convertCoord(select(section, ".//Arrival//Station/@x")[0].value),
          time: makeTimestamp(date, select(section, ".//Arrival//Arr/Time/text()")[0].data),
          platform: strip(getData(select(section, ".//Arrival//Arr/Platform/Text/text()")[0]))
        },
        journey: journey,
        transport: {
          name: strip(select(section, ".//Journey//Attribute[@type='NAME']//Text/text()")[0].data),
          direction: strip(select(section, ".//Journey//Attribute[@type='DIRECTION']//Text/text()")[0].data)
        }
      });
github stefanw / vbb-json / lib / vbb.js View on Github external
var parseBasicStop = function(stop, date) {
  station = select(stop, ".//Station");
  if (station.length) {
    var arrival = null, arrivalPlatform = null;
    var departure = null, departurePlatform = null;
    if (select(stop, ".//Arr").length) {
      arrival = makeTimestamp(date, select(stop, ".//Arr/Time/text()")[0].data);
      arrivalPlatform = strip(getData(select(stop, ".//Arr/Platform/Text/text()")[0]));
    }
    if (select(stop, ".//Dep").length) {
      departure = makeTimestamp(date, select(stop, ".//Dep/Time/text()")[0].data);
      departurePlatform = strip(getData(select(stop, ".//Dep/Platform/Text/text()")[0]));
    }
    return {
      name: select(stop, ".//Station/@name")[0].value,
      id: select(stop, ".//Station/@externalId")[0].value,
      lat: convertCoord(select(stop, ".//Station/@y")[0].value),
      lng: convertCoord(select(stop, ".//Station/@x")[0].value),
      arrival: arrival,
      arrivalPlatform: arrivalPlatform,
      departure: departure,
      departurePlatform: departurePlatform
    };
  }
};

xpath

DOM 3 XPath implemention and helper for node.js and the web

MIT
Latest version published 11 months ago

Package Health Score

77 / 100
Full package analysis