Reply To: Script for getting XML to ID from webserver

#62360

Using the built-in “Prompt” command:

id = prompt (“Article Id: “, '');
if (id != null)
{
app.activeDocument.importXML(File(“~/Documents/”+id+”.xml”));
}

Where it says '~/Documents/”, you must fill in the default path you are using. Make sure to end it with a /slash/ — except when there is some text in the file name before the unique id, of course.

This requires you to enter the exact ID. Another possibility could be to have a script first scan the default path for all files ending with “.xml” and then present this list to you, so it's really just a point-and-click excercise. But I'm not sure that would work on a server as well — getting the names of files in a folder is meant to, well, get the names of files in a folder. :)

If you want to experiment with this, try the following script. Enter your server path at the prompt and check if it returns anything useful.

folderName = prompt (“Get XML file list from: “, '');
if (folderName != null)
{
filenames = Folder(folderName).getFiles(“*.xml”);
alert ('Files in '+folderName+':r'+filenames.join('r'));
}

This article was last modified on June 7, 2012

Comments (0)

Loading comments...