CML
    Preparing search index...

    Function serializeXml

    • Basic xml encoding utility. Encodes XML into a string.

      Parameters

      • xml: XmlNode

        The XML node to encode

      Returns string

      The parsed XML

      const xml = {
      nodeName: '#document',
      nodeValue: null,
      attributes: {},
      childNodes: [
      {
      nodeName: 'root',
      nodeValue: null,
      attributes: {},
      childNodes: [
      {
      nodeName: 'child',
      nodeValue: null,
      attributes: {
      hello: 'world',
      } as Record<string, string>,
      childNodes: [
      {
      nodeName: '#text',
      nodeValue: 'text',
      attributes: {},
      childNodes: [],
      },
      ],
      },
      {
      nodeName: 'ns:tag',
      nodeValue: null,
      attributes: {},
      childNodes: [
      {
      nodeName: '#text',
      nodeValue: 'content',
      attributes: {},
      childNodes: [],
      },
      ],
      },
      ],
      },
      ],
      }

      equal(serializeXml(xml), '<?xml version="1.0" encoding="UTF-8"?><root><child hello="world">text</child><ns:tag>content</ns:tag></root>')