7 Replies Latest reply on Feb 7, 2014 11:51 AM by MW Design

    Import XML with images and text

    Mr-MK

      Hi!

       

      I have a design on one page, ït´s like a product folder. I alos have about 500+ artikles (One article per page)

       

      I have used the XML import before for Business Cards but now i would like to make my product presenation. I also would like to save each presentation as a single JPG.

       

      Anyone that have a tutorial for this?

       

      Today i have a template for how this product presenation shpoul look like, som of the items should be bound to my XML file such as price, image on the article and title.

       

      I have tryed to save my indesign file as xml but the xml file is empty.

       

      Regards

      MR-MK

        • 1. Re: Import XML with images and text
          MW Design Level 4

          Without seeing your template, I have no idea how it is set up.

           

          This is a snippet from an XML file I used for another user's example file...

           

          <Series>Series Mark Three Widgets</Series>

          <image href="file:///../images/vinyltape.jpg"></image>

          <Widget><WidgetName>Awesome Widget Eight</WidgetName>

          ...

          (more stuff removed...)

           

          The above second line is how an image is referenced in the XML file, and indicates the images for the sample are in a sub-folder of where the InDesign file and its XML file are located. It is a reletive path.

           

          When the XML is read in, assuming the paragraph styles are set up (in this case they are), then it produces this:

           

          capture-001079.png

           

          If you InDesign Template has no text in it (just styles, etc), then the XML will be empty. Add some sample data, then export that and you should have a sample XML file for which to base your working XML file upon. But do note that the XML ID exports is rather ugly and unformatted. It will also convert the paths to images as a full path that should be edited so the hrefs are not tied to a single computer.

           

          The above sample isn't really usable for you, but I can make it available for you to look at if desired. I doubt it in anyway corresponds to your project.

           

          Mike

          • 2. Re: Import XML with images and text
            Mr-MK Level 1

            Hi and thanks for a fast reply!

             

            My XML looks like this:

             

             

            <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

            <Root>

            <head>BMW X5 (E70) 2006 Ù</head>

              <image href="file:///C:/Users/mk/Pictures/picture1.jpg"></image>

              <nofoil>some

              text

              here</nofoil>

              <foottext>text in the footer</foottext>

            </Root>

             

            the document looks a little bit like this:

             

            dump-test.png

             

            i have a databse with about 6000 articles in 5 different languages and can create one xml file for each article och one xml with all articles...

             

            But what i want´t is to in a easy way create all product sheets in a easy way and whith good quality..

             

            /MK

            • 3. Re: Import XML with images and text
              MW Design Level 4

              Hello MK,

               

              It appears to me that your need would be satisfied with creating a run-in template. Then it would be used on your XML files either individually, or with combining the XML into logical groups of XML files inserted into each other. 6000 articles would likely be a bit unweildly and likely would overtax ID.

               

              Here are a couple links from my link stash that might aid you.

              http://instantindesign.com/?view=388

               

              In the linked page in the following link, the second one on the page is likely what is of most use.

              http://carijansen.com/category/publishing/xml/

               

              If you don't think the above will aid you enough to get going on modifying your template, let me know. I would likely need you to ZIP up a couple XML files, the relevant images and the ID template. Then put it up on wikisend.com, dropbox.com or your own server. Then send me a Private Message with the link. You can opt to send me a private message by clicking on my name and you should see in the profile a link to write the PM.

               

              Take care, Mike

              • 4. Re: Import XML with images and text
                Mr-MK Level 1

                Thanks Mike!

                 

                so far so good! i have now a template in Indesign and about 400 xml files,

                 

                I have tested to change the links to the xml fle and that works fine.

                 

                Now i would like to make a script, that does this job for me.

                 

                Open the template, loop the directory with the xml files, change the link för the xml, export image as JPG...

                 

                 

                But i can´t find any information about how to work with Extend Toolkit. A couple days ago i saw something about this on youtube i think...

                 

                 

                /MK

                • 5. Re: Import XML with images and text
                  MW Design Level 4

                  Very good! Unfortunately, I cannot help on a scripting solution.

                   

                  I would search/review threads in the Scripting forum for something someone has already written. If something isn't obvious to tweak for your needs, I would inquire there:

                  http://forums.adobe.com/community/indesign/indesign_scripting?view=discussions

                   

                  Take care, Mike

                  • 6. Re: Import XML with images and text
                    Mr-MK Level 1

                    Thanks Mike for your help...

                     

                    i think i solvded it... I made a template in indesign, i had a folder with all my xml files (imade a script to export them from the database as separate xml files)

                     

                    then i made this code:

                     

                    var myTemplate = File("/C/path/to/template/temp2.indd"),
                    myFolder =Folder("/C/path/to/xmlfiles/XML/"),
                    myDocs = myFolder.getFiles("*.xml");

                    alert(myDocs.length);


                    for (var i =0; i < myDocs.length; i++) {
                    if (i==10)
                    {
                    break;   
                        }
                       
                        var newdoc = app.open(myTemplate),
                        mydoc = app.activeDocument;
                        newdoc.importXML(myDocs[i]);
                       
                        var newfilename = myFolder.absoluteURI + "/output2/" + myDocs[i].name.replace(/xml/,"indd"); 
                        var newfilename2 = myFolder.absoluteURI + "/output2/" + myDocs[i].name.replace(/xml/,"jpg");
                           
                           
                        
                              var myPageName = newdoc.pages.item(0).name;
                              app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.medium; // low medium high maximum
                              app.jpegExportPreferences.exportResolution  = 72;
                              app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
                              app.jpegExportPreferences.pageString = myPageName;
                             
                              //var myFilePath = "~/Desktop/" + myBaseName  + "_" + myPageName + ".jpg";
                              var myFile = new File(newfilename2);
                              newdoc.exportFile(ExportFormat.jpg, myFile, false);
                       
                            newdoc.save(new File(newfilename));
                           
                            mydoc.close();
                        }

                     

                     

                     

                     

                    Now i can run this script and it will create one *.indd file and one jpeg...

                     

                     

                    GREAT!

                     

                     

                    I can reduce my self with a script!

                     

                    /MK

                    • 7. Re: Import XML with images and text
                      MW Design Level 4

                      Excellent result, MK

                       

                      Take care, Mike