InDesign XML Import

Tutorial with free working Template

This InDesign XML tutorial describes a sample end-to-end workflow for XML pagination in Adobe InDesign. We’ll learn how to create a car catalog importing a XML file in InDesign.

  • You can freely download the InDesign XML project template from the button above and start practice with XML import in InDesign.
  • In your downloaded zip file, you will find a sample XML file, an IDML template, and the final document in PDF and InDesign format, complete with images and fonts.

InDesign XML workflows allow for close control over a document’s graphical elements and enable you to automate almost any kind of layout. But XML has a steep learning curve, and a dedicated team can be required to establish, maintain, and troubleshoot the logic behind even relatively simple operations.

Looking for an even better InDesign automation? Pagination offers solutions to overcome XML Import issues.

Table of Contents

  1. Editing the InDesign template
  2. Configuring the image fields
  3. Two InDesign tools
  4. Setting up the InDesign template
  5. XML Import
  6. Mapping the XML structure
  7. Importing XML data (paginating)
  8. InDesign or InDesign Server?

 

InDesign XML Strategies and Tutorial with Template

Editing the InDesign template

Let’s start by taking a brief look at the XML file structure. In this tutorial we want to merge a list of cars. Each car has attributes that need to be imported (‘BRAND’, “CAR_MODEL’, ‘TYPE’ etc.) as well as an image.

Configuring the image fields

InDesign will only include an image field if a href attribute is added as an XML element. A href attribute requires an image’s relative or absolute image URL.

Examples of absolute URLs include:

On a Windows system – href = “file:///C:/Images/car.psd”
On a Mac system – href = “file:///Users/user-name/Documents/car.psd”

Relative URL paths are taken from the XML file’s save location. Example of relative URLs include:

href = “file:///car.psd” (when the image and XML file share a folder)
href = “file:///Images/car.psd”
href = “file:///…/Images/car.psd”

All URLs must include the string ‘file:///’ as a prefix.

Two InDesign tools

The next step involves two InDesign tools. The first is the Structure panel. This panel contains all elements from our XML content. It also allows us to add, edit and delete elements and attributes to/from the existing structure. Access the Structure panel through View -> Structure -> Show Structure.

The second tool is the Tags panel. This panel contains a list of tags that are used for assigning XML elements that should be imported to the InDesign document. We can assign tags to texts and image placeholders. Access the Tags panel through Window -> Utilities -> Tags.

Setting up the InDesign template

We start a new InDesign document through File -> Document. For this tutorial we’ll uncheck ‘Facing Pages’, check ‘Primary Text Frame’ and select two columns.

We can now open the master page and customize it with our project layout and header/footer objects.

XML Import

Return to the document’s first page and open the Structure panel. Click on ‘Import XML’ from the menu in the panel’s top-right corner (or through File -> Import XML in the main InDesign menu).

This option will open a new dialog box. Choose our XML file and check the ‘Show XML Import Options’ and ‘Merge Content’ options before opening it.

Uncheck all boxes in the next dialog box and then press ‘OK’.

The XML file has now been imported into our document. The document structure has been populated like the XML file, and the Tags panel has also been populated with the XML file’s corresponding elements.

We only need one car element for the mapping stage. Delete the rest from the Structure panel by selecting them, right clicking and pressing ‘Delete’.

Mapping the XML structure

We map the imported XML file by dragging and dropping elements from the Structure panel into the document or assigning tags to the document from the Tags panel.

Start by assigning the car’s root element with a specific object within the document. Do this by selecting a car from the Structure panel and dragging it over the main text frame on the first page. The frame will then be populated with all of the values and images that are contained within the car’s structure.

All fields are marked with square brackets and labeled with colors that match the Tags panel.

Be aware that some unwanted characters may have been inserted alongside the imported fields (e.g. tab and paragraph return characters). A useful tool for removing these characters can be found by selecting the text and choosing Edit -> Edit in Story Editor.

Reveal hidden characters by choosing Type -> Show Hidden Characters. Then proceed to delete any that are unnecessary.

Note: making text changes directly within the text frame offers the same results as edits made in the Story Editor, but using the Story Editor shows XML fields’ full names (vs. only simple brackets). This extended form can drastically simplify the editing process.

We can now customize our fields with InDesign’s graphic tools (paragraph styles, character styles, frame options etc.). In our example we’ve added labels before each field and given these labels a bold character style.

We can also make changes to the fields found above our main image – BRAND, CAR_MODEL and TYPE. We start this process by creating paragraph styles called ‘Brand’ and ‘Model’.

Next click on the top-right menu in the Tags panel and click on ‘Map Tags to Styles’. This will display a dialog box in which we can assign one of our paragraph styles to each tag – so in our case the ‘Brand’ paragraph style to the BRAND tag and the ‘Model’ paragraph style to the CAR_MODEL and TYPE tags.

Clicking ‘OK’ should reveal the following result:

Our final customization step involves adjusting the image frame. Start by selecting the frame and reducing the width. Then right click inside the frame, select Fitting -> Frame Fitting Options and selecting ‘Auto-Fit’ and ‘Fit Content Proportionally’. Ensure that all ‘Crop Amount’ values are set to 0. All newly imported images will now be fitted to the same frame size.

We’ve now completed the graphical customization. The following screenshot compares the preview and standard versions of our car style:

Save the document as an InDesign template (.indt format) and then close and reopen it.

The close and reopen step is important as we’re now opening an unnamed template instead of a named document. We can therefore reuse the template across numerous projects, which is especially useful if you’re creating huge catalogs, e.g. to have different, custom-named documents for each category.

Importing XML data (paginating)

The last section of this InDesign XML tutorial will see all of the cars’ elements imported to our template.

The process uses the same ‘Import XML’ method as above. As such: open the Structure panel and click on ‘Import XML’ from the menu in the panel’s top-right corner (or through File -> Import XML in the main InDesign menu). Choose our XML file and check both the ‘Show XML Import Options’ and ‘Merge Content’ options.

We now need to choose several options in the ‘XML Import Options’ dialog:

  • Create link: Ensures that any changes made to the imported XML file will be reflected in the new InDesign document.
  • Clone repeating text elements: Useful when your XML files have repeating elements, e.g. the repeating car elements in our file. InDesign will check these elements during the import process and clone them in the new document.
  • Do not import contents of whitespace-only elements: Prevents the import of elements that contain only whitespaces or break characters (e.g. paragraph returns).
  • Delete elements, frames and content that do not match imported XML: Deletes all content in the new document that is not found in the XML file.

Click on ‘OK’ in ‘XML Import Options’ to merge the new InDesign document with the XML elements.

You may notice that the BRAND and CAR_MODEL elements have been separated:

Correct this by selecting the ‘Brand’ paragraph style from the Paragraphs panel, right clicking and choosing ‘Edit Brand’. Then navigate to the ‘Keep Options’ section and add ‘1’ to the ‘Keep with Next’ field. This option will keep all ‘Brand’ styles together with the next styles.

It's done!

Do the same for the ‘Model’ paragraph style and then you’re complete!

InDesign or InDesign Server?

Adobe InDesign Server is far less known than its desktop alternative. In this article, we outline what Adobe InDesign Server is, when to use it, and why and how Adobe InDesign Server is different from Adobe InDesign Desktop.

2 responses to “InDesign XML Data Import”

  1. darren says:

    How did you add the line border in the template? No matter where I add a dotted line or use Shift+hyphen to get a continuous line, the paragraph styles and tags of the imported xml gets messed up

  2. Michael Allen Campassi says:

    Great tutorial.
    I have a question about images import
    I have to produce pages that include
    Athlete Name
    Athlete School
    Athlete Sport
    and a photo of the athlete
    Is there a way to have the xml look into subfolders to find images
    Also the only common attribute for the athlete is there last name
    However sometimes the image file will be named
    Isabelle2.jpg
    or ReinaSausedo1.jpg
    So is there a way to have the xml look for just a part of the athletes name as a variable since the image file names are all over the place.

Leave a Reply

Your email address will not be published. Required fields are marked *

Limitations

Users often find InDesign XML Import to be complicated and inefficient because:

  • You have to convert your data to XML and this is a complex project by itself (free tutorial and samples data here: from Excel to XML)
  • XML templates creation and InDesign field-mapping are rigid, and you have to foresee and hard-wire many basic typographic conventions in your templates.

To overcome these limitations there is a powerful solution that helps you create your documents faster and easier, and is called Pagination.

 

watch demo

Create your automated document!

Use one of our free InDesign Templates or upload your own layout. Create documents anytime and from anywhere.