< Back
Print

Building XML Target Keys

When building an XML export a textual representation of the intended XML tags (<example>) and attributes (attribute=”example”) must be entered in the connector. These have the following syntax:

target-key|sub-target-key@attribute=attribute-value

Best explained in an example. Let’s say, we want to build the following XML.

<product number=”PN-10254”>
  <name>Smart LED TV</name>
</product>

We would need to enter the following target key:

product@number=PN-10254|name

The value “Smart LED TV” will then be exported into the tag “name”. In a production export the “number” will vary for each product, so it would look like this:

product@number={productNumber}|name

We would use the placeholder function of the connector with “productNumber” and fill this placeholder with the product number of the currently exported product.

It should be mentioned that an infinite amount of sub-target keys can be used. For example:

product|media|images|main

would create:

<product>
  <media>
    <images>
      <main></main>
    </images>
  </media>
</product>

And of course, also an infinite amount of XML attributes:

product@number={productNumber},update=true|name@lang={StoreView}

results in:

<product number=”PN-10254” update=”true”>
  <name lang=”en”>Smart LED TV</name>
</product>

“StoreView” is a pre-defined placeholder.

Special Target Keys & Pre-defined Placeholders

The XML connector supports various special target keys that are often used in combination with our pre-defined placeholders.

multival

Configuring two datamap rows with the same key will cause them to overwrite each other. The last one “wins”.

Configuration:

Output:

<PRODUCT_ID>12875</PRODUCT_ID>
<LABEL lang="x-default"><![CDATA[Unser Bester Coffee]]></LABEL>
<LABEL lang="en"><![CDATA[Unser Bester Coffee]]></LABEL>
<LABEL lang="de"><![CDATA[Unser Bester Coffee]]></LABEL>
<LABEL lang="fr"><![CDATA[Unser Bester Coffee]]></LABEL>
<LABEL lang="jp"><![CDATA[Unser Bester Coffee]]></LABEL>
<EXTERNAL_KEY><![CDATA[unserBesterCoffee]]></EXTERNAL_KEY>

This can be circumvented by using XML attributes like this, because then they are treated as different target keys:

Output:

<PRODUCT_ID>12875</PRODUCT_ID>
<LABEL lang="x-default"><![CDATA[Unser Bester Coffee]]></LABEL>
<LABEL lang="en"><![CDATA[Unser Bester Coffee]]></LABEL>
<LABEL lang="de"><![CDATA[Unser Bester Coffee]]></LABEL>
<LABEL lang="fr"><![CDATA[Unser Bester Coffee]]></LABEL>
<LABEL lang="jp"><![CDATA[Unser Bester Coffee]]></LABEL>
<EXTERNAL_KEY order="1"><![CDATA[Unser Bester Coffee]]></EXTERNAL_KEY>
<EXTERNAL_KEY order="2"><![CDATA[unserBesterCoffee]]></EXTERNAL_KEY>

But there are many use-cases where the XML tags shall be duplicated but no XML attributes are intended. In this case the special XML attribute “multival” can be used. It acts like any other attribute and allows duplicate XML tags but is not included in the output.

Configuration:

Output:

<PRODUCT_ID>12875</PRODUCT_ID>
<LABEL lang="x-default"><![CDATA[Unser Bester Coffee]]></LABEL>
<LABEL lang="en"><![CDATA[Unser Bester Coffee]]></LABEL>
<LABEL lang="de"><![CDATA[Unser Bester Coffee]]></LABEL>
<LABEL lang="fr"><![CDATA[Unser Bester Coffee]]></LABEL>
<LABEL lang="jp"><![CDATA[Unser Bester Coffee]]></LABEL>
<EXTERNAL_KEY><![CDATA[Unser Bester Coffee]]></EXTERNAL_KEY>
<EXTERNAL_KEY><![CDATA[unserBesterCoffee]]></EXTERNAL_KEY>

[arrayKey] or [{StoreView}] brackets

Square brackets in the target can be used to signal to the connector that multiple value groups will be filled into the parent element. The value inside the brackets separates these value and avoids overwriting. Just like “multival”, the brackets will not be included in the output.

In this example, “product|attributes|[shoppingfeed-attributes]” creates a big list of attributes with sub-XMLs specifying each attribute. This list needed to be expanded by other configurations, hence the square brackets were used here to signal these multiple value groups to the connector.

When using long target keys with multiple XML attributes, it can sometimes be necessary to use the bracket, so that the value can be exported.

Example:

category|attribute-groups|attribute-group@group-id=spec_storefront_attributes|display-name[{StoreView}]@xml:lang={StoreView}

inline-container

(Since Version 1.20.0)

Entering the target key “inline-container” will directly insert your format result XML into the final XML without this key.

Normally the XML connector needs a container tag for the exported data such a “product” or “category”. Example:

<product number=”PN-10254”>
  <name>Smart LED TV</name>
  <price>249.99</price>
  <description>A high-quality TV</description>
</product>

But in some use cases you will need multiple base containers for one product. For example with product-to-category assignments such as these:

<category-assignment category-id="217" product-id="10254">
  <primary-flag><![CDATA[true]]></primary-flag>
</category-assignment>

<category-assignment category-id="314" product-id="10254">
  <primary-flag><![CDATA[false]]></primary-flag>
</category-assignment>

<category-assignment category-id="801" product-id="10254">
  <primary-flag><![CDATA[false]]></primary-flag>
</category-assignment>

You can achieve this by using the XML tag “inline-container” and a loop format with “Create XML using placeholders”, since the created XML snippets will then directly be inserted into your exported XML.

Was this article helpful?
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Table of Contents