docx
    Preparing search index...

    Function convertToXmlComponent

    • Converts an xml-js Element into an XmlComponent tree.

      This function recursively processes XML elements in JSON format (from xml-js) and creates a tree of ImportedXmlComponent objects that match the structure of the original XML.

      Parameters

      • element: Element

        The XML element in JSON representation from xml-js

      Returns string | ImportedXmlComponent | undefined

      An ImportedXmlComponent tree, text string, or undefined

      const xmlElement = xml2js('<w:p><w:r><w:t>Hello</w:t></w:r></w:p>');
      const component = convertToXmlComponent(xmlElement);