Stefan Cameron on Forms
Building intelligent forms using Adobe LiveCycle Designer

Tip: Pretty XML Strings

I regularly use the saveXML() method, available on all node class-based objects, as a way to debug my forms (think of it as a type of introspection technique). The method outputs a string representation of the XML content of the node in question, which helps when attempting to discover the underlying object structure without a debugger…

For example, say you have a simple form with a text field and a numeric field. The following statement will output the form’s data to the JavaScript Console in Acrobat:


The result, however, isn’t very readable:

<?xml version="1.0" encoding="UTF-8"?>
<xfa:data xmlns:xfa=""

Though I had been using saveXML() for quite some time, I hadn’t realized that it actually takes an optional parameter, a string with a value of “pretty”, that results in much nicer output.


results in the following pretty/readable output:

<?xml version="1.0" encoding="UTF-8"?>
<xfa:data xmlns:xfa="">

Posted by Stefan Cameron on August 19th, 2009
Filed under Debugging,Scripting,Tips
Both comments and pings are currently closed.

Comments are closed.