2 Replies Latest reply on Jan 10, 2011 10:53 PM by Stephanomic

    Export storie in xml format



      I am a beginer in InDesign scripting and I want to export all stories entries in a document to an XML format file.

      Please anyone can help me?



        • 1. Re: Export storie in xml format
          [Jongware]-9BC6tI Level 4

          It's easy to export one story to an XML file:


          app.selection[0].parentStory.exportFile(ExportFormat.XML, File("/c/test.xml"));


          (this will export the story your cursor is in), but exporting more than one story into the same file is a problem. It's possible to loop over all stories and export them one by one, but:


          1. You need to write them to separate files (because that's how exportFile works), and

          2. You cannot automatically glue them together into one file afterwards. Each XML file starts with a header, and after that ech XML file should only contain one single root object.


          Depending on your exact needs, it might be possible to do the XML export "manually", i.e., opening a new file, writing the XML header and root tag, then loop over each story (adding yet another 'enclosing' tag) and each story's XMLElements and outputting them one by one.


          I haven't need this before, so I cannot help you with that, but reading the Javascript Programmer Reference ought to give you some handles on this.

          • 2. Re: Export storie in xml format
            Stephanomic Level 1


            I've found one solution to put all storie in a collection

            So, I have a problem to write in the xml out file

            this is my code

            // Création de l'arbre XML
            var myXmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
            myXmlString += "<Index />";
            var myXml = new XML(myXmlString);
            myXml.name = myDocument.fullName.name;


            and this return an error like "XML does not have a costructor"