Converting XML tags to EasyCatalog Tags

EasyCatalog has the ability convert XML tags to EasyCatalog tags via a simple LUA script that maps tag attributes to the elements of a link (key, data source, field name).

The .lua script should be placed inside a folder called “Adopt Fields” in the “Scripts” folder of a data source.  The file name of the script must contain “XML” – for example, ‘Adopt XML.lua’ – to differentiate this as an XML adoption (rather than an EasyCatalog link > EasyCatalog link adoption).

When correctly installed, the script name shows up on the “Adopt Fields->” sub menu. When actioned, all the XML tags in the document are processed. For each XML tag and attribute encountered, the LUA script will be passed a variable called ‘tagname’ which contains the name of the XML tag being processed. Each of the attributes on the XML node will be passed trough as separate variables so, for example when the following XML tag is encountered…

… the LUA script will be called with the following variables:

The script should set up to three strings, which instruct EasyCatalog which record in the panel to link the XML tag to:

  1. key – Key field value.
  2. datasource – Data source name (optional, will already be set to the name of the data source you’re adopting to).
  3. field – Name of a field.

Using the XML node above, the following LUA script will map the ‘id’ attribute to be EasyCatalog’s key field value and the ‘name’ attribute to be the field name in the panel: