Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I read and navigate an XML file in JavaScript for Photoshop?

New Here ,
Dec 11, 2009 Dec 11, 2009

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!

TOPICS
Actions and scripting
2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Guru ,
Dec 11, 2009 Dec 11, 2009
LATEST

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');

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines