Creates an ImportedXmlComponent.
The XML element name
Optional_attr: any
Optional attributes for the root element
Internal
A component of no element, such as the one fromXmlString gives for the parsed document, is written as the
elements in it. Written as itself, it would be an <undefined> element, which Word can't open.
The component itself is still returned, rather than its element, because code written for earlier versions takes the element from its children.
Adds a child element to this component.
The child component or text string to add
This component (for chaining)
Prepares this element for XML serialization. A component of no element written by itself, rather than among a parent's children, such as by the formatter or by an earlier copy of docx, is written as the one element in it.
The serialization context
The XML-serializable object
Adds a child component or text to this element.
The child component or text string to add
StaticfromParses an XML string and converts it to an ImportedXmlComponent tree.
This static method is the primary way to import external XML content. It parses the XML string into an XmlElement tree, then converts that into a tree of XmlComponent objects.
The component is for the parsed document, with the XML's element in it, and is written as that element, with no element of its own around it.
The XML content as a string
An ImportedXmlComponent representing the parsed XML
XML component representing imported XML content.
ImportedXmlComponent allows you to parse XML strings and incorporate them into the document structure. This is particularly useful when working with templates or when you need to include pre-existing XML fragments.
Example