docx
    Preparing search index...

    Function convertToXmlComponent

    • Converts an XML element, in the shape of xml-js's non-compact Element, into an XmlComponent tree.

      This function recursively processes the element and creates a tree of ImportedXmlComponent objects that match the structure of the original XML.

      Parameters

      Returns string | ImportedXmlComponent | undefined

      An ImportedXmlComponent tree, text string, or undefined

      const component = convertToXmlComponent({
      type: "element",
      name: "w:p",
      elements: [{ type: "element", name: "w:r", elements: [{ type: "element", name: "w:t", elements: [{ type: "text", text: "Hello" }] }] }],
      });