Copy link to clipboard
Copied
I would like to know if it is possible to use an XML file containing multiple book records so that I could create a window listing all these records for the user to choose. I've tried using the manuals but they seem to me that they are meant for other features, and I'm not sure it's possible to do what I need.
Thanks
Given that you have the following xml structure:
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book name="Book 1"/>
<book name="Book 2"/>
<book name="Book 3"/>
<book name="Book 4"/>
</books>
Then you can have
...var main = function() {
var m = $.os[0]=="M",
wF = "XML Files : *.xml",
mF = function(f){return (f instanceof Folder ) || /\.xml$/.test(f.name)},
filter = m? mF : wF,
f = File.openDialog ("Please select xml file", filter),
books, nBook, arr = [], n = 0, i = 0;
if ( !f ) return;
f.en
Copy link to clipboard
Copied
Given that you have the following xml structure:
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book name="Book 1"/>
<book name="Book 2"/>
<book name="Book 3"/>
<book name="Book 4"/>
</books>
Then you can have
var main = function() {
var m = $.os[0]=="M",
wF = "XML Files : *.xml",
mF = function(f){return (f instanceof Folder ) || /\.xml$/.test(f.name)},
filter = m? mF : wF,
f = File.openDialog ("Please select xml file", filter),
books, nBook, arr = [], n = 0, i = 0;
if ( !f ) return;
f.encoding ="UTF-8";
f.open('r');
x = XML( f.read() );
f.close();
books = x..book;
n = books.length();
if ( !n ) return;
while ( i<n ) {
nBook = books;
arr.push ( String( nBook.@name ) );
i++;
}
openWindow ( arr );
}
var openWindow = function(arr) {
var w = new Window('dialog'),
ls = w.add('listbox', undefined, arr),
btn = w.add('button', undefined, 'Cancel');
w.show();
};
var u;
main()
And see the result

Get ready! An upgraded Adobe Community experience is coming in January.
Learn more