Atn to XML

Discussion of the xtools Toolkit

Moderators: xbytor, DavideBarranca, Paul MR

Post Reply

Atn to XML

Post by myranalis » Sun Nov 06, 2011 4:14 pm

Morning all. Long time no see

I'm back to working on another project - using the ActionFileToXML.jsx file as an example I've tried to read an atn file in an dump it to an XML using :

Code: Select allvar actFile = new ActionFile();;
var xml = actFile.toXML(;
// xml = xml.toXMLString(); <- this throws an error?
Stdlib.writeToFile(pOutputFolder + "/Original.xml", xml, 'UTF-8', 'unix');

If I leave the xml.toXMLString() commented out, all appears to work fine except the XML is stripped of all the id and key attributes that are present if I convert it with the original ActionFileToXML script.

If I uncomment that line, it throws an error that toXMLString is not a function. Given the code above is almost identical to that found in the process section of ActionFileToXML I'm at a loss as to what I've managed to muck up. Any idea what I'm doing wrong?



Atn to XML

Post by xbytor » Sun Nov 06, 2011 6:09 pm

Here is the canonical way to do what you want using the more recent versions of xtools and PS (probably CS3+).

Code: Select all//
//@show include
//@includepath "/c/Program Files/Adobe/xtools;/Developer/xtools"
//@include "xlib/PSConstants.js"
//@include "xlib/Stream.js"
//@include "xlib/stdlib.js"
//@include "xlib/GenericUI.jsx"
//@include "xlib/Action.js"
//@include "xlib/xml/atn2bin.jsx"
//@include "xlib/xml/action2xml.jsx"
//@include "xlib/ActionStream.js"
//@include "xlib/ieee754.js"

function main() {
  var file = File("~/work/xtools/etc/XToolkit.atn");
  var actFile = new ActionFile();;
  var xml = actFile.toXML();
  Stdlib.writeXMLFile("~/Desktop/Output.xml", xml);

// EOF

The important bit is that action2xml.jsx is used instead of atn2xml.jsx. atn2xml implements a early version of ActionFile for versions of PS that did not have the XML object implemented. action2xml does create a proper XML object so toXMLString() will work.


Atn to XML

Post by myranalis » Sun Nov 06, 2011 9:14 pm

Thanks x. That seems to have done the trick.

Post Reply