Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
I have opened ChocolateSheet5 from the Exercise Files, and this is a clean document, not the template we were working on in earlier movies. You can see that in the Tags panel, we don't have any tags in here, there is no tags applied to objects in the document at all. So we have been given the task of exporting this content as XML. Now, I do want to be clear that in general I recommend having InDesign be a container for receiving XML rather than a source of exporting XML. It's cleaner to start with your XML outside of InDesign and then drop it into an InDesign template as we saw in the last few movies, but if you do need to get your content out of a document here is what you can do.
The first thing we need is tags. I could make them one at a time, as we saw in an earlier movie, but I am just going to import them using Load Tags. I am going to just select this XML file that I have inside of the Exercise Files that has all of the tags in it. Now I am going to tag these objects in my document, just like I did in earlier movies. I will select this head at the top and I will click on Header. I will select the story here and click on story. I will click the subhead here, and I believe this is called caption. There we go. That's supposed to get the caption tag. Now let's get those images: Number 1 and Number 2.
Let's view the structure in the Structure Pane by pressing Cmd+Opt+1 or Ctrl+Alt+1 on Windows, and I will twirl down this little triangle here to see the structure here. Now, I do remember that in the XML file I want, in the structure that I want, I want to put the caption between the two images; I just remembered that, so I better just drag that down to put it in the right order. Now, inside this story, this text frame or this text thread that I tagged with the story tag, we have multiple paragraphs. In fact, if I zoom in here with Cmd+2 or Ctrl+2 on Windows, we can see that not only do we have multiple paragraph styles, we also have character styles in here as well. But all I did was apply the story tag to the whole thing.
Well, in order to tag the paragraph and the character styles in here properly I need to map those character styles and paragraph styles to proper tags in the XML. The way I am going to do that is to go to the Tags panel flyout menu, and choose Map Styles to Tags. That's different than what we saw before, before we mapped tags to styles, now we are mapping styles to tags. Now, in this case I am only going to be mapping the tags for these paragraph and the character styles, and I happen to know that that is the Body Paragraphs style, and I am going to map that to bodytext tag in the XML. Also, the Italic character style should map to emphasis.
When I click OK, you can see -- well, it's a little hard to see, but there's little yellow tags around the italic text here, and that yellow is the emphasis tag has been applied. Over in the Structure panel I can see that I have some extra twirly triangles here, and if I click on those, I can see all of the different paragraphs that had been affected here. They have all been tagged and if I look inside this bodytext paragraph, there is the emphasis tag. Another way to see the structure of this story is to look at it in Story Editor. So while this is selected on the Document Page, I am going to go to Edit and choose Edit in Story Editor. Story Editor is a wonderful way to look at tagged text, because it's much easier to see things like, that's emphasis text, than it is to look for these little tiny brackets on the page here.
We can also apply tags here. For example, I will just select these four words here and click on the emphasis tag, and you can see that it shows up here, and it shows up as tagged down here. What's more, if we look at our Structure Pane, we see that we have one more emphasis tag in the structure as well. Okay, now that we have everything tagged, let's go ahead and export the XML. I am going to export the entire document here as XML by choosing Export XML from the Structure panel menu. Another way to do this would be to choose Export from the File menu and just do the normal export dialog box route; both do exactly the same thing.
We will name it here; tell it where to save the XML file. Click Save, and we will see the Export XML dialog box. I am not going to go through all of these options right now, because they get kind of technical, but I will tell you the ones that are most important. First of all, we are going to view the XML after its exported using whatever application you want to use. I have a text editor on the Mac here called TextWrangler. This is my favorite text editor on the Mac, its a free text editor, and it works really well for viewing text, so that's what I have chosen here. But if you have another application that handles XML or text, you can choose it from this pop-up menu.
We are going to be Exporting From the Selected Element here. Because we have selected Root, so we are just going to grab the entire thing. If we had Tables then we might want to export them as CALS XML, but I am not going to worry about that now, I have no tables in here. Now, Remap Break, Whitespace, and Special Characters is important in my experience, because InDesign seems to put in a lot of weird characters in the XML, and sometimes that can really mess up a text editor or an XML Editor, so I recommend that you always Remap those Break, Whitespace, and Special Characters to other characters in the XML, it's just safer that way.
In an earlier movie I was talking about XSLT and how it's like a supercharged Find/Change feature. If you have an XSLT that you want to use, you can Apply it here upon export, and all of your XML will be pushed through that Find/Changer thing and it will turn into something different, whatever the XSLT tells it to do. XSLTs are quite powerful. You can turn almost anything into anything else. For example, I have seen XSLTs that will take regular XML and convert it into HTML, so that would be an option here for your XML.
I also want to point out, there is an Images tab of the Export XML dialog box, and this gives you control over how you want your images to be exported. Typically, you just get an XML file, just the text file, but if I turn on any of these checkboxes then I actually get the images themselves inside an Images Subfolder; it will copy them into an Images Subfolder for me. That could be useful in certain circumstances. The Original Images, it's obvious it just copies the entire original image: the Photoshop files, or TIFFs or JPEGs or whatever. But Optimized Original Image will actually convert those images into JPEGs and GIFs for me.
I have to tell you, I am not a fan of this. I personally feel like Photoshop would be a better tool, or Fireworks, or almost anything else would be a better tool than InDesign for converting images into GIFs or JPEGs, so I don't use that. But I will point out that if you are going to do it, you might want to use this Optimized Formatted Images option instead, because that will actually crop and scale and rotate and whatever. It will format those images and then convert them to JPEGs or GIFs on the fly. So in this case, I don't want any of those images, I just wanted to let you know that that was an option.
I am going to click Export, and it will export the XML and open it up in the text editor, in this case TextWrangler. If you squint here you can really see that all of the data is there: the headers and the story and the emphasis information, and so on and so on, it's all there, including the graphics and the images at the end, and so on. Now, just because I have exported XML successfully from InDesign doesn't mean that I can turn around and reimport it back into InDesign. That's called round tripping. While it is possible to round-trip your XML in some situations, I have to tell you that in most cases it won't work right without some significant massaging. In fact, in general, you should probably expect to do some cleanup of InDesign's XML files, whether this is headed to the web or to a database or back into some other InDesign template.
Nevertheless, the ability to get XML out of InDesign can be incredibly useful, especially in a fast-paced production environment, where you need to repurpose your content everyday.
Get unlimited access to all courses for just $25/month.Become a member
117 Video lessons · 43812 Viewers
119 Video lessons · 54844 Viewers
65 Video lessons · 15001 Viewers
113 Video lessons · 83079 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.
Your file was successfully uploaded.