@svta/common-media-library
    Preparing search index...

    Function parseXml

    • Beta

      Parse XML into a JS object with no validation and some failure tolerance

      Parameters

      • input: string

        The input XML string

      • options: XmlParseOptions = {}

        Optional parsing options

      Returns XmlNode

      The parsed XML

      const obj = parseXml(
      `<root>
      <child>text</child>
      <ns:tag>content</ns:tag>
      </root>`,
      );
      assert(obj.childNodes[0].nodeName === 'root');
      assert(obj.childNodes[0].childNodes[0].nodeName === 'child');
      assert(obj.childNodes[0].childNodes[0].childNodes[0].nodeValue === 'text');
      assert(obj.childNodes[0].childNodes[1].nodeName === 'ns:tag');
      assert(obj.childNodes[0].childNodes[1].prefix === 'ns');
      assert(obj.childNodes[0].childNodes[1].localName === 'tag');