docx
    Preparing search index...

    Class Endnotes

    Base class for all XML components in WordprocessingML documents.

    XmlComponent provides the infrastructure for building XML element trees that are serialized into document.xml and other parts of the DOCX package. It manages a collection of child components and handles the conversion to the intermediate object format used by the xml serialization library.

    // Creating a custom XML component
    class MyElement extends XmlComponent {
    constructor(text: string) {
    super("w:myElement");
    this.root.push(new Attributes({ val: text }));
    }
    }

    const element = new MyElement("Hello");
    // When serialized: <w:myElement w:val="Hello"/>

    Hierarchy (View Summary)

    Index
    • get writtenAs(): readonly BaseXmlComponent[] | undefined
      Internal

      The components written in this one's place, one after another, when it can't be written as a single element, such as a run with another run in its children. Undefined when it is written as itself.

      Returns readonly BaseXmlComponent[] | undefined