How to use the xml2js.parseStringPromise 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 elastic / kibana / packages / kbn-test / src / failed_tests_reporter / get_failures.ts View on Github external
export async function getFailures(log: ToolingLog, testReportPath: string) {
  const xml = await readAsync(testReportPath, 'utf8');

  // Parses junit XML files
  const report: TestReport = await xml2js.parseStringPromise(xml);

  // Grab the failures. Reporters may report multiple testsuites in a single file.
  const testSuites = 'testsuites' in report ? report.testsuites.testsuite : [report.testsuite];

  const failures: TestFailure[] = [];
  for (const testSuite of testSuites) {
    for (const testCase of testSuite.testcase) {
      const { failure } = testCase;

      if (!failure) {
        continue;
      }

      // unwrap xml weirdness
      const failureCase: TestFailure = {
        ...testCase.$,
github elastic / kibana / packages / kbn-test / src / failed_tests_reporter / test_report.ts View on Github external
export async function parseTestReport(xml: string): Promise {
  return await xml2js.parseStringPromise(xml);
}
github eclipse / codewind / src / pfe / portal / modules / metricsService / index.js View on Github external
async function injectMetricsCollectorIntoPomXmlForSpring(pathToPomXml) {
  const originalPomXmlFileData = await fs.readFile(pathToPomXml);
  const originalPomXml = await xml2js.parseStringPromise(originalPomXmlFileData);
  const newPomXmlInJsonFormat = getNewContentsOfPomXmlForSpring(originalPomXml);
  const xmlBuilder = new xml2js.Builder();
  const newPomXml = xmlBuilder.buildObject(newPomXmlInJsonFormat);
  log.debug(`Injecting metrics collector into project's pom.xml, which is now:\n${newPomXml}`);
  await fs.writeFile(pathToPomXml, newPomXml);
}
github eclipse / codewind / src / pfe / portal / modules / metricsService / index.js View on Github external
async function injectMetricsCollectorIntoPomXml(pathToPomXml) {
  const originalPomXmlFileData = await fs.readFile(pathToPomXml);
  const originalPomXml = await xml2js.parseStringPromise(originalPomXmlFileData);
  const newPomXmlInJsonFormat = getNewContentsOfPomXml(originalPomXml);
  const xmlBuilder = new xml2js.Builder();
  const newPomXml = xmlBuilder.buildObject(newPomXmlInJsonFormat);
  log.trace(`Injecting metrics collector into project's pom.xml, which is now ${util.inspect(newPomXml)}`);
  await fs.writeFile(pathToPomXml, newPomXml);
}
github jsforce / jsforce / src / api / wsdl / wsdl2schema.ts View on Github external
async function readWSDLFile(filePath: string) {
  const xmlData = await fs.readFile(filePath, 'utf8');
  const json = await xml2js.parseStringPromise(xmlData, {
    explicitArray: false,
  });
  return castTypeUsingSchema(json, WSDLSchema) as WSDL;
}