Attributes (in elements)

In this post, we will learn:


Have you encountered the need to work with attributes in elements when processing product data and don’t know what they are for or how to use them? In MERGADO Editor, which is based on XML, you can easily work with them and increase your sales. Let’s talk about what attributes in elements are and how MERGADO can help you with them.

What are attributes?

Simply put: XML files consist of elements that carry information. And an attribute is a part of an element that specifies the meaning of the element. They are the bearers of the refining value. These values must always be enclosed in quotes or apostrophes.

Example: If we wanted to create an XML file with the names of the party attendees and their gender, the structure using an attribute would look like this:

<person gender="female">

In the person element there is a gender attribute (dark blue color) with the value female (red color). This attribute specifies that Pavlína Nováková identifies herself as female.

Without the attribute, this entry could have this structure:


Example: Shoptet uses attributes for image descriptions:

   <IMAGE description="Zimní bunda Columbia (Barva Zelená, Velikost L)">ázev_obrázku.jpg</IMAGE>

:warning:  Google does not use element and attribute partitioning in its nomenclature as XML files do. It only uses the attribute label (for both elements and attributes). See Google specification.

What are attributes for?

Attributes in product feeds

For our personal purposes, it doesn’t matter what structure we write the birthday person in (the first example), as long as it’s functional. However, if we want to sell our products on various advertising portals, we may run into a problem. This is because some portals require sending product data with attributes in elements. Such portals are for example Ceneo, Heureka Availability, Shoptet and many more.

Example: Ceneo

    <a name="Producent">Nike</a>

Example: Heureka Availability

    <item id="314141-120">
    <delivery_time orderDeadline="2023-04-17 12:00">2023-04-26 12:00</delivery_time>

Example: Shoptet

    <IMAGE description="Columbia Squish N’ Stuff (Barva Zelená, Velikost L)">ázev_obrázku.jpg</IMAGE>
    <IMAGE description="Columbia Squish N’ Stuff (Barva ČErvená, Velikost S)">ázev_obrázku.jpg</IMAGE>

Attributes and MERGADO Editor

You can work with attributes across the entire MERGADO Editor. With these edits you can:

  • Offer your items on portals that require the use of attributes.
  • Remove unwanted attributes and override attribute values.
  • Create product queries based on attributes.
  • Generally, we can work with attributes wherever element names appear: for example, in rules or MQL.

Attributes are recognized in the Editor by having the at sign @ at the beginning. Let’s show this with an example. We have the following input feed:

    <SHOPITEM id="DEF87">
            <IMAGE description="desc image"></IMAGE>

The feed contains the SHOPITEM element, which has the id attribute in it. Next, we see the IMAGE element with the desc attribute. In the MERGADO Editor we see the above mentioned attributes with an at sign:

  • @id on the Elements page:

  • @description on the Elements page:

  • @id in the element input:

  • @description in the element input:

:information_source:  In the MERGADO Editor we can also encounter so-called special attributes. We can recognize them by starting with two at signs, e.g. @@POSITION or @@VALUE.

Examples of usage

1. In the rule form we target the element CODE of one specific variant which has the attribute @id (of the element VARIANT) with the value idvariant3:

    <VARIANT id="idvariant3">
    <VARIANT id="idvariant4">

The path to the element CODE will be: VARIANTS | VARIANT { @id ~ "idvariant3" } | CODE.

2. On the Products page we are looking for a product with the defualt category with the attribute @id = 123:

    <CATEGORY id="456">Electronics</CATEGORY>

The condition for the query will be: CATEGORIES | DEFAULT_CATEGORY | @id = "123".