Skip to content

What This Adds In Cloud Code

  • Converts XML payloads to JS-friendly objects.
  • Option aliases for easier migration (fromXML, fromXml, parse).
  • Good fit for SOAP or XML webhook integrations.

Quick Start

js
const XML = require('xml');
const parsed = XML.parse('<order><id>100</id></order>');

API

FunctionParamsReturnsNotes
fromXML(xml, options)XML string + optionsobjectAlias of parser.
fromXml(xml, options)XML string + optionsobjectAlias of parser.
parse(xml, options)XML string + optionsobjectMain parser function.

Common options:

  • mode: hash or hash_no_attrs (default: hash_no_attrs)
  • strip_namespace: default true
  • indent: default 2

Practical Example

js
const XML = require('xml');

const payload = XML.parse(request.params.soap_response_xml, {
  mode: 'hash',
  strip_namespace: true
});

response.success({ status: payload?.Envelope?.Body?.Result?.Status });

Failure Modes & Gotchas

  • Invalid XML throws conversion error.
  • Unknown option keys are rejected by runtime sanitization.