Accessing XML data as a DOM object - tooltwist/xdata GitHub Wiki
The class com.tooltwist.xdata.DomXml is used as the selector for "xml-dom".
If you wish to access and manipulate the data as a DOM object, you can request the selector this way.
DomXml domXml = (DomXml) data.getSelector("xml-dom");
You can manipulate the DOM object as much as you wish, but you must tell XData once you've finished making changes, so it can discard data in any other data formats.
Document document = domXml.getDocument();
// Do stuff to the document here
domXml.notifyChanged();
If you skip this step, then asking for the string representation of the data, or convert to another data format, will be inconsistent with the changes you have made.
Useful functions
The DomXml class contains many functions that simplify manipulating DOM objects, and merging them into XD objects. See the Javadoc for the complete list.
Other Information
Important: The indexes used in paths to access DOM via XPath are different to the indexes used in XData selection paths.
- XPath indexes start at one (except in Internet Explorer).
- XData selector indexes start at zero.