1. Selecting an ENTIRE xml document doesn't work as the XML prolog throws it off - run the script against the document with the prolog unselected and you should be fine.
2. The script only seems to work against 8-bit character encoded files (i.e. UNIX or DOS shown in the status bar). If you're running the script against selected text in a file recognized as Unicode or UTF-8 with Unicode editing, then the script will fail.
- Code: Select all
// When invoked, this script expects that the user has selected a well-formed
// block of XML. It then overwrites that XML fragment in-place with a pretty-
// printed version.
// The scripting engine included with UltraEdit-32 is based on Ecma-357 (E4X),
// which is the same language used within Adobe Flex. Thus, the following site
// was used as a reference in creating this script:
XML.ignoreComments = false;
XML.ignoreProcessingInstructions = false;
XML.ignoreWhitespace = true;
XML.prettyPrinting = true;
XML.prettyIndent = 2;
var xmlNode = new XML( UltraEdit.activeDocument.selection );
UltraEdit.activeDocument.write( xmlNode.toXMLString() );