# Attributes (in elements)

**URL:** <https://forum.mergado.com/t/attributes-in-elements/676>\
**Category:** Elements\
**Tags:** mergado-2\
**Created:** [May 3, 2023, 11:32am UTC](https://forum.mergado.com/t/attributes-in-elements/676 "2023-05-03T11:32:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lehuy](https://forum.mergado.com/user_avatar/forum.mergado.com/lehuy/32/280_2.png) [@lehuy](https://forum.mergado.com/u/lehuy)\
**Post date:** [May 3, 2023, 11:32am UTC](https://forum.mergado.com/t/attributes-in-elements/676/1 "2023-05-03T11:32:26Z")

</div>

In this post, we will learn:

- [What are attributes?](https://forum.mergado.com/t/attributes-in-elements/676#what-are-attributes-2)
- [What are attributes for?](https://forum.mergado.com/t/attributes-in-elements/676#what-are-attributes-for-3)
- [Attributes and MERGADO Editor](https://forum.mergado.com/t/attributes-in-elements/676#attributes-and-mergado-editor-5)
- [Examples of usage](https://forum.mergado.com/t/attributes-in-elements/676#examples-of-usage-6)
- [Summary](https://forum.mergado.com/t/attributes-in-elements/676#summary-7)

## Introduction

Have you encountered the need to work with attributes in [elements](https://forum.mergado.com/t/elements/501) 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](https://forum.mergado.com/t/elements/501#element-in-xml-feed-2), 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](https://forum.mergado.com/t/elements/501#element-in-xml-feed-2) consist of [elements](https://forum.mergado.com/t/elements/501) 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:

```auto
<person gender="female">
    <firstname>Pavlína</firstname>
    <lastname>Nováková</lastname>
</person>

```

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:

```auto
<person>
    <gender>female</gender>
    <firstname>Pavlína</firstname>
    <lastname>Nováková</lastname>
</person>

```

**Example:** [Shoptet](https://www.mergado.com/tag/shoptet) uses attributes for **image descriptions** :

```auto
<IMAGES>
   <IMAGE description="Zimní bunda Columbia (Barva Zelená, Velikost L)">https://cdn.myshoptet.com/název_obrázku.jpg</IMAGE>
</IMAGES>

```

> ⚠ &nbsp;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](https://support.google.com/merchants/answer/7052112?hl=en).

## 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](https://www.mergado.com/supported-channels)**, 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](https://www.mergado.com/tema/ceneo), [Heureka Availability](https://www.mergado.com/tag/heureka), [Shoptet](https://www.mergado.com/tag/shoptet) and many more.

**Example: Ceneo**

```auto
<attrs>
    <a name="Producent">Nike</a>
</attrs>

```

**Example: Heureka Availability**

```auto
<item_list>
    <item id="314141-120">
    <stock_quantity>1</stock_quantity>
    <delivery_time orderDeadline="2023-04-17 12:00">2023-04-26 12:00</delivery_time>
</item>

```

**Example: Shoptet**

```auto
<IMAGES>
    <IMAGE description="Columbia Squish N’ Stuff (Barva Zelená, Velikost L)">https://cdn.myshoptet.com/název_obrázku.jpg</IMAGE>
    <IMAGE description="Columbia Squish N’ Stuff (Barva ČErvená, Velikost S)">https://cdn.myshoptet.com/název_obrázku.jpg</IMAGE>
</IMAGES>

```

### 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](https://forum.mergado.com/t/simple-search/473) based on attributes.
- Generally, we can work with attributes wherever element names appear: for example, in [rules](https://forum.mergado.com/t/rules-in-mergado/494) or [MQL](https://forum.mergado.com/t/mql-language/755).

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:

```auto
<SHOP>
    <SHOPITEM id="DEF87">
        <CODE>7DW890</CODE>
        <EXTERNAL_ID>ALERNARIVE798</EXTERNAL_ID>
        <NAME>Žehlicka</NAME>
        <IMAGES>
            <IMAGE description="desc image">www.zehlicka-image.com</IMAGE>
        </IMAGES>
    </SHOPITEM>
</SHOP>

```

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](https://forum.mergado.com/t/mergado-2-elements/586):  
 ![image](https://forum.mergado.com/uploads/default/original/1X/1545f908e403855c6b191510b0c6c884a5818073.png)

- @description on the Elements page:  

- @id in the element input:  

- @description in the element input:  

> ℹ &nbsp;In the Mergado Editor we can also encounter so-called [special attributes](https://forum.mergado.com/t/special-attributes/749). We can recognize them by starting with two at signs, e.g. [@@POSITION](https://forum.mergado.com/t/position/766) or [@@VALUE](https://forum.mergado.com/t/value/751).

## Examples of usage

1.&nbsp;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:

```auto
<VARIANTS>
    <VARIANT id="idvariant3">
        <CODE>EEQ21</CODE>
        <UNIT>unit</UNIT>
        <FREE_SHIPPING>1</FREE_SHIPPING>
        <FREE_BILLING>1</FREE_BILLING>
    </VARIANT>
    <VARIANT id="idvariant4">
        <CODE>EEQ22</CODE>
        <UNIT>unit2</UNIT>
        <FREE_SHIPPING>0</FREE_SHIPPING>
        <FREE_BILLING>0</FREE_BILLING>
    </VARIANT>
</VARIANTS>

```

[The path to the element](https://forum.mergado.com/t/element-path/753#what-is-path-to-element-2) CODE will be: `VARIANTS | VARIANT { @id ~ "idvariant3" } | CODE`.

2.&nbsp;On the [Products page](https://forum.mergado.com/t/mergado-2-the-products-page/587) we are looking for a product with the defualt category with the attribute @id = 123:

```auto
<CATEGORIES>
    <DEFAULT_CATEGORY id="123">Appliances</DEFAULT_CATEGORY>
    <CATEGORY id="456">Electronics</CATEGORY>
</CATEGORIES>

```

The [condition](https://forum.mergado.com/t/mql-language/755#what-is-a-condition-in-mql-3) for the query will be: `CATEGORIES | DEFAULT_CATEGORY | @id = "123"`.

## Summary

- [What are attributes?](https://forum.mergado.com/t/attributes-in-elements/676#what-are-attributes-2)  
An attribute is a part of an element that **specifies the meaning of the element**.

- [What are attributes for?](https://forum.mergado.com/t/attributes-in-elements/676#what-are-attributes-for-3)  
Some portals require **sending product data with attributes in elements**. Such portals are for example [Ceneo](https://www.mergado.com/tema/ceneo), [Heureka Availability](https://www.mergado.com/tag/heureka), [Shoptet](https://www.mergado.com/tag/shoptet) and many more.

- [Attributes and MERGADO Editor](https://forum.mergado.com/t/attributes-in-elements/676#attributes-and-mergado-editor-5)  
Generally, we can work with attributes wherever element names appear: for example, in product [queries](https://forum.mergado.com/t/simple-search/473/1), [rules](https://forum.mergado.com/t/rules-in-mergado/494) or [MQL](https://forum.mergado.com/t/mql-language/755).
