Copy link to clipboard
Copied
I am using JavaScript for Photoshop to create a series of image labels. I have the labels stored in an XML file. How can I read an XML file from Javascript in Photoshop and navigate the XML document?
I have seen many examples of people creating XML files in JavaScript, but I haven't seen good documentation on the XML object, its methods and properties. Sample code would be appreciated too.
Thanks!
Copy link to clipboard
Copied
The javascript tools guide has info about working with xml. Here is one way to read the file.
var f = new File('~/Desktop/testing/gallery.xml');
f.open('r');
var xml = new XML( f.read() );
f.close();
// photos node
var photoXML = xml.child('photos');
// first photo
var photo1XML = photoXML.child(0);
var title = photo1XML.child('title');
Find more inspiration, events, and resources on the new Adobe Community
Explore Now