Converts XML to JSON and vice-versa using node-expat parser
Overall
score
93%
Generate an XML feed for storefront inventory where null optional fields are removed unless explicitly included.
description: null), the generated XML excludes those element tags while retaining siblings, including other optional fields with actual values. @test"", numeric zero 0, or boolean false still emit elements with those values, demonstrating that only null is suppressed. @test<description/>) so feeds can show explicit placeholders. @test@generates
/**
* Builds an XML string representing an inventory feed with optional suppression of null fields.
*
* @param {object} inventory - Root object with an `items` array of records containing identifiers and optional metadata.
* @param {object} [options]
* @param {boolean} [options.includeNull=false] - Emit empty elements for null-valued fields when true; otherwise omit them.
* @returns {string} XML string encoding the inventory data.
*/
export function buildInventoryXml(inventory, options = {});Converts JS objects to XML while supporting omission of null-valued children. @satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-xml2jsondocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10