What is XML and why do I care?

Client data is at the centre of all we do.  We lay it out, back it up, email it, proof it, PDF it, and put it on the web.  To get data into our systems we retype it, cut and paste it, and scan it.  How does XML fit into these activities?
XML is the standard way of defining any collection of digital data. XML can define a business card, a catalogue, a brochure, or even a novel.  The person creating the data file defines the names to describe the data, as in the example below of a business card.

XML defines the data only, other programs will define how it is laid out. Its basic and straightforward nature is why XML is important.  Everything that comes in contact with this data file can display it in a way that is unique to its platform: a web page, a cell phone, a spreadsheet, an email, and even InDesign and Quark.
You will certainly come in contact with an XML file sooner or later, so it’s best to learn about it in small doses so that you’ll be ready for the file when you do encounter one. Even I, someone who enjoys scripting, found that learning the nuts and bolts of XML made my eyes heavy.
So with that in mind, following are some XML basics.
It is simple to get started with XML in InDesign, but you must pay attention when using the palettes.  Go to View -> Show Structure and you have your tools for importing XML. Go to Window -> Tags to view the tags palette.
If you have a layout, you can add XML placeholders to it.  Bring in your XML file using File -> Import XML and the structure of the data appears in the window.  The structure shows the names of the data, not the data itself.  If you select “Show Text Snippets” from the Structure Menu it will show you a bit of what is in the file. You can then drag and drop the parts of the data you want in your file.
When you bring in the XML file, the tags palette automatically adds all the items from the file. Just two warnings: If you use the tags palette to add tags, the tags palette can change the name of the items in your existing structure. Second, once an item is tagged, it belongs to the structure.  If the structure is deleted, so is all the data.
XML and Stylesheets in InDesign go hand in hand.  You create your stylesheets and map your data to the style or vice versa, and InDesign will apply the styles when the data comes in.  It is important to remember that the structure in your window must be the same as the one in your file.
Both Javascript and Applescript are capable of automating the importing of XML files.  I recently designed a workflow that picks up a piece of data from a webpage and places it in InDesign with styles and saves as a PDF.
Curiously enough, Quark 7, which was designed using XML, requires an extension for importing actual XML files.  XML does not even appear in the index of Quark’s help window.
The Adobe Classroom in a Book has an XML Tutorial, and you can access information via the internal InDesign Help. I have also listed some websites below so that you may start learning about XML today, and you can download a sample InDesign and XML file at www.tribay.ca. If you heed my advice and take it bit by bit, and you’ll be ready when someone gives you an XML file.
http://www.xml.com/lpt/a/1456
http://www.topxml.com/xml/LearnXML.asp
http://www.codeproject.com/soap/XmlHelper.asp    
Andrea Mahoney
TriBay Enterprise
T: 416.729.9687
www.tribay.ca

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -

Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /var/www/easywp-plugin/wp-nc-easywp/vendor/wpbones/wpbones/src/Database/WordPressOption.php:141 Stack trace: #0 /var/www/easywp-plugin/wp-nc-easywp/plugin/Http/Varnish/VarnishCache.php(296): WPNCEasyWP\WPBones\Database\WordPressOption->set() #1 /var/www/wptbox/wp-includes/class-wp-hook.php(308): WPNCEasyWP\Http\Varnish\VarnishCache->doPurge() #2 /var/www/wptbox/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters() #3 /var/www/wptbox/wp-includes/plugin.php(517): WP_Hook->do_action() #4 /var/www/wptbox/wp-includes/load.php(1124): do_action() #5 [internal function]: shutdown_action_hook() #6 {main} thrown in /var/www/easywp-plugin/wp-nc-easywp/vendor/wpbones/wpbones/src/Database/WordPressOption.php on line 141