< 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

Documentation coming soon …

[] or [{placeholder}] or [arrayKey]

Documentation coming soon …

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