Native Data DOM XML
Unit: HPDFXFARuntime
Methods
dataNode.loadXML(xml, ignoreRoot = true, overwrite = false);
const compact = dataNode.saveXML();
const readable = dataNode.saveXML("pretty");
These script methods are available on datasets, dataGroup and dataValue nodes in TXFAWidgetRuntime events
saveXML returns UTF-8 XML with a declaration and the selected node as its document element; the optional pretty argument adds indentation to element-only content
loadXML accepts one well-formed XML document; ignoreRoot imports its children into the selected node, while False imports the source document element as a child
overwrite removes existing target content before importing; its default False appends content and preserves existing child identities
The selected node retains its identity and attributes; imported child attributes and their namespace mappings are preserved
Immediate graph and bindings
const record = xfa.datasets.data.main;
record.loadXML("<main><amount>42</amount></main>", true, true);
const amount = record.amount;
amount.value = "43";
if (this.parent.amount.rawValue !== "43") throw new Error("Missing binding update");
A successful native parse immediately installs the imported children in the current script graph; ordinary properties and SOM selectors resolve those fresh nodes before event publication
Data cells synchronize with bound field aliases in both directions, including hidden fields, newly supplied binding targets and existing descendant, wildcard, class and numeric-index dataRef selectors
Scalar-to-group imports update the target's data class and expose its imported child elements; an emptied dataValue has an empty string value
Importing a new data element does not allocate unrelated ambiguous data leaves for unresolved bindings
Identity and repeated scopes
Overwrite invalidates old child handles and publishes fresh child identities; a script object can retain a fresh imported data handle and use it in subsequent events
Appending preserves existing handles; importing inside a repeated row changes that row's native data scope and bound fields
XML imports also work inside an occurrence created by addInstance during the same event
Replacing the datasets content updates $data and $record to the new native roots, and rebases surviving form and script-object identities so lexical module state remains attached to its form scope
Content and persistence
Native imports and saved XDP preserve ordinary text, CDATA, comments and processing instructions in order
Comments and processing instructions remain outside ordinary Data DOM element selection and do not become visible field text
Imported nodes preserve their namespace URI even beneath a different ancestor default namespace, including the explicit empty default namespace for no-namespace elements
Foreign prefixed attributes retain expanded names, and Unicode local names, accented text and supplementary characters survive native save and reload
Read-only saveXML does not materialize form properties or change saved XDP bytes
Validation and rollback
The native XML parser checks well-formedness, namespace and attribute validity, XML characters, declaration placement and entity syntax before graph mutation
Malformed input can be caught in JavaScript; the previous native and script graph remains available, and a later valid mutation can still commit
A failed event restores the document bytes, widget values, imported graph, identities and script-object lexical state, including failures after the native XML import has already been applied
Each native JavaScript session retains its actual DLL module while rebuilding engines for response replay; engines, contexts and journals remain independent, and the module reference is released after the final native engine teardown
XML parsing and serialization enforce operation, depth, node, byte and elapsed-time budgets together with the runtime's original event deadline and value-character limits
Imports do not resolve external entities or perform file, network or UI actions; DTD declarations are rejected by this parser
Current scope
This event-runtime integration currently targets Windows Win32 and Win64; portable Linux runtime integration remains pending
This integration supplies native XML import and serialization plus current binding reevaluation; standalone createNode, arbitrary data attribute mutation, reparenting, record-window navigation, binding predicates and global-binding policy remain separate object-model targets
Related APIs
Native Data DOM, Native Bind SOM, TXFAEventBinding, TXFAEventAction and Interactive XFA Runtime