Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Script for getting XML to ID from webserver

Return to Member Forum

  • Author
    Posts
    • #62359
      Anonymous
      Inactive

      At work (the Dine Penger – Your Money magazine) we are changing our workflow. Now we are writing all stuff in our CMS, and import it to Indesign as XML from the webserver.

      All the articles get their exlusive id-number. But the import to Indesign (windows) from a link is a bit tedious. we need to import via links that formats as: https://username:password@previ…..ign/unique id].

      The only thing changing from article to article is the ID.

      So: Anyboy know a script that we can run – put in the unique id, and get the import done?

      I am thinking that the rest of the information (link, username and password) could be stored in the script or some kind of settings, and that the only thing the designers need is a dialoque box to put in the id.

      I think this would be fairly easy, but I dont know any scripting myself.

      (BTW: We need username/password because of IT-regulations…).

    • #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'));
      }

Viewing 1 reply thread
  • You must be logged in to reply to this topic.
Forum Ads