Return to Developer Support
DOM4J is an open source XML library used by EditMe to provide XML capabilities to Layout scripts. While typical layouts do not need to access the XML at this level, DOM4J provides another option for advanced developers looking to work with XML data in a structured way.
Using DOM4J in EditMe
The following example shows how to set the content of a tag by ID in a layout using XPATH:
var setme = layout.selectSingleNode("//*[@id='setme']");
setme.text = setme.name + ' tag text set in pre-press script.';
<p id="setme">p tag text set in pre-press script.</p>
In order to use the DocumentHelper class, you need to access it as follows. Here is an example that creates a new Document instance with a root element named "root":
var newDoc = Packages.org.dom4j.DocumentHelper.createDocument();
newDoc.rootElement = Packages.org.dom4j.DocumentHelper.createDefaultElement('root');
As EditMe expands the capabilities of layout scripting, DOM4J will prove useful for managing XML data in Page content. This documentation will be updated in the future with examples of how this and other tasks are accomplished.