Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
We are starting off with our document in the same state as it was at the end of the last movie, so if you didn't watch that one first, you may want to go do that now. We have tagged each of the frames that we want to populate with XML content, so now it's time to import our XML file. To do that, I am going to choose the Root element, this top Root element in the Structure pane. Now, I will choose Import XML either from the File menu or the Structure pane flyout menu. I will choose one of these XML files, and then I want to make sure that Show XML Import Options is on. I always want to have that checkbox on.
Also, because I chose the Root element first, it gives me the option to Import Into that Selected Element; in this case I definitely want to do that. Then it lets me either Merge or Append the content. Merge means, well, it means basically the same thing as Import Into Selected Element. It means put all that incoming XML information into the elements in here, inside Root. That's what we want. Append Content means add that information after the XML information that's already here. That's not really going to do us any good in this case. We want to merge it into the selected element.
I will click Open and we get the XML Import Options dialog box. The first option here is Mode. We can choose Merge Content or Append Content, which is basically the same choice that we just made a moment ago. I really have no idea why they put that pop-up menu here. I guess maybe if you change your mind or something. Next, you have the option to create a link. This is very interesting, because it means that if your XML file changes, we can update it in InDesign automatically. I will show you that in a minute. I will go ahead and turn that one on.
XSLT is kind of a supercharged find/ change feature, which lets you change aspects of the XML file upon importing. You might use an XSLT in order to move things around. For example, if your XML file doesn't match the structure of your InDesign structure, you could use an XSLT to move it around, or you could add static elements that you want to put inside these frames that aren't actually in the XML file. There is a lot of ways that you can use XSLT files, but that's pretty advanced, and I am not going to get into it anymore right now.
Clone repeating text elements is the key to importing lots and lots and lots of XML data and make it repeat in your InDesign file. For example, you could import 10,000 different elements inside an InDesign file and have it automatically add it one after another. So that's what that's about. In this case it's not really relevant, so I am going to leave that turned off. Only import elements that match existing structure has to do with the structure of the XML file and the structure of the InDesign file. Your XML file may have a lot of elements that don't exist in the InDesign structure, and so you have a choice of whether to import those or just ignore them. In this case I am going to go ahead and import them by leaving this checkbox unchecked.
The next item here, Import text elements into tables if tags match, has to do with importing XML data obviously into a table. Well, we would need a table obviously and we would need to tag every cell inside that table and we need to make sure that the names of each of those cells match the names of the elements in the XML. I just have to tell you, it is fraught with peril. It is really complicated getting tabular data from an XML file into an InDesign table. It's possible, but I have just heard so many people have troubles with that.
Anyway, in this case it's completely irrelevant because I don't even have a table in this document. Now, whitespace elements. A lot of people insert whitespace elements, in other words, tabs or returns or extra spaces, or things, just to format the XML file and make it look pretty. Well, that is stuff we do not want to have in our InDesign document, we would like InDesign to strip all of that extra whitespace stuff out before it gets into the InDesign document. So I am going to go ahead and turn on Do not import the contents of whitespace-only elements, so I will leave that off.
The next option has to do with what do you want to have happen if some data doesn't come in. For example, let's say this image down here doesn't show up in the XML file, there is no second image, so what do you want to have happen, do you want that frame to still be there? Well, if I turn on this checkbox then InDesign will literally delete that whole object if the incoming XML doesn't have that element in it. So that could be really useful depending on your situation. The last item here, Import CALS tables as InDesign tables. All I can say about that is, if you don't know what a CALS table is then you don't need to know what a CALS table is. So I would just leave it on or off, it's not going to bother me any.
Let's go ahead and click OK and see what happens. There we go. All the data came in just the way we had hoped. We have the title and the bodytext, the images, the subhead, and so on and so on. By the way, these images look a little bit strange to me. That's because the tags are still showing for these outlines. It actually has a color that sits on top of the image. So we can get around that simply by going into Preview Mode. Let's see. We will go into Preview Mode there, and now we don't see any of that additional tag information. In fact, why don't I drop this tag into the docs so we don't have to see that panel either? That is looking really, really good.
If we zoom in here, we can actually see that even the character styles have been applied in the proper place. Okay. Remember that I linked this XML file to the file on disk. So if I look in my Links panel I can see, there it is, there is the XML file, it has a little green checkmark saying, that is okay, everything is good to go. But the cool thing is, we can now edit the XML file and have it update automatically in InDesign. So I have selected that in the Links panel and I am going to click on the Edit Original. It opens the XML file in my default XML Editor here.
Why don't I change the name of the Header? I will just call this Yummy Ganache instead. I am going to save it; I just did Cmd+S or Ctrl+S on Windows, and I will go back to InDesign and look what happens. In a second it just updates automatically, it's great. There is a live link between the XML file and InDesign. The reason it updated automatically of course is that I used the Edit Original button. If I had edited it elsewhere, not used the Edit Original, then I would have gotten a little status update here saying that it had been updated, and then all I would have to do is click on the Update button instead. But either way, it's great to have this live link.
So that's it. We now have a working template with tagged frames. Each time the data changes, we simply update the XML file and import it into the InDesign document, or just update that link if we used the Create Link feature. But what if you have been handed an InDesign document and you need to get the XML out of it, not in? Well, that process is similar but with some important differences. Let's take a look in the next movie.
Get unlimited access to all courses for just $25/month.Become a member
120 Video lessons · 64657 Viewers
119 Video lessons · 71917 Viewers
125 Video lessons · 32519 Viewers
84 Video lessons · 18989 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.