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 Nomenclature, 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 record information. And an attribute is a part of an element that specifies its meaning. They are the bearers of the refining value. These values must always be enclosed in quotes or apostrophes.
For 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">
<firstname>Pavlina</firstname>
<lastname>Novakova</lastname>
</person>
In the “person” element there is a “gender” attribute (purple 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:
<person>
<gender>female</gender>
<firstname>Pavlína</firstname>
<lastname>Nováková</lastname>
</person>
For example, Shoptet uses attributes for image captions:
…
https://cdn.myshoptet.com/image_name.jpg
…
Attributes in product feeds
For our personal purposes, it doesn’t matter what structure we write the birthday person in, 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 or Shoptet.
…
Ceneo:
<attrs>
<a name=”Producent”>Nike</a>
</attrs>
…
Heureka Inventory feed:
<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>
…
Shoptet:
<IMAGES>
<IMAGE description="Columbia Squish N’ Stuff (Colour Green, Size L)">[https://cdn.myshoptet.com/název_obrázkujpg](https://cdn.myshoptet.com/n%C3%A1zev_obr%C3%A1zkujpg)< /IMAGE>
<IMAGE description="Columbia Squish N’ Stuff (Colour Green, Size L)">https://cdn.myshoptet.com/název_obrázku.jpg< /IMAGE>
</IMAGES>
In the case of an XML feed with products, the attributes are, for example, a SHOPITEM
code specification or a specification of the source where the product image is located:
<SHOP>
<SHOPITEM id="DEF87">
<CODE>7DW890</CODE>
<EXTERNAL_ID>ALERNARIVE798</EXTERNAL_ID>
<NAME>Iron</NAME>
<IMAGES>
<IMAGE description="desc image">www.zehlicka-image.com</IMAGE>
</IMAGES>
Note: 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?
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 selections based on attributes.
- And work with them wherever element names appear: for example, in rules or MQL.
Attributes in MERGADO Editor
Attributes are recognized in the Editor by having the at sign @
at the beginning. Let’s show this with examples. We have the following input feed:
<SHOP>
<SHOPITEM id="DEF87">
<CODE>7DW890</CODE>
<EXTERNAL_ID>ALERNARIVE798</EXTERNAL_ID>
<NAME>Iron</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:
Note: 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.
Examples of usage
See examples of use:
1) Looking for products with size 30 shoes to select from the feed:
<PARAM>
<PARAM_NAME>Shoe size</PARAM_NAME>
<VAL>30</VAL>
</PARAM>
MERGADO 1: PARAM |Shoe size = "30"
MERGADO 2: PARAM {PARAM_NAME = "Shoe size"} | VAL = "30"
If we know the exact position of the element in the feed, the expression can also look like this:
MERGADO 2: PARAM { @@POSITION = 2 } | VAL = "30"
If the feed contains multi-value elements <VAL>
with the value 30 at the second position within the feed, it will return all such products.
MERGADO 2: PARAM { @@POSITION = 3 } | VAL = "30"
There is no <VAL>
with a value of 30 in in the third position. So the path (element-path) is not correct.
2) We are looking for an outfit whose size is greater than 1.
<PARAM>
<PARAM_NAME>Size</PARAM_NAME>
<VAL>2</VAL>
</PARAM>
MERGADO 1: PARAM|Size > 1
MERGADO 2: PARAM {PARAM_NAME = "Size"} |VAL > 1
3) I want to change the negative value in the shipping price:
<DELIVERY>
<DELIVERY_ID>PPL</DELIVERY_ID>
<DELIVERY_PRICE>-120.00</DELIVERY_PRICE>
<DELIVERY_PRICE_COD>190</DELIVERY_PRICE_COD>
</DELIVERY>
<DELIVERY>
<DELIVERY_ID>DELIVERY</DELIVERY_ID>
<DELIVERY_PRICE>-59.00</DELIVERY_PRICE>
<DELIVERY_PRICE_COD>128</DELIVERY_PRICE_COD>
</DELIVERY>
Create the selection as follows:
DELIVERY | DELIVERY_PRICE CONTAINS "-"
In the rule Bulk override values select the element:
DELIVERY | DELIVERY_PRICE
and choose what values to overwrite with the new one.
Nothing has changed for simple elements!
4) Looking for gift boxes in CUSTOM_LABEL_0:
<CATEGORYTEXT>Food & Beverage | Food | Food Gift Baskets</CATEGORYTEXT>
<CATEGORYTEXT>Gift Boxes</CATEGORYTEXT>
<CUSTOM_LABEL_0>Gift Boxes</CUSTOM_LABEL_0>
<PRODUCT>Fitness box with crowbar, Box for men, Gifts for men, Gifts for women</PRODUCT>
MERGADO 1: CUSTOM_LABEL_0 = "Gift Boxes"
MERGADO 2: CUSTOM_LABEL_0 = "Gift Boxes"
5) I am looking for products where the name contains bed and the price is more than 4000,-
MERGADO 1: PRODUCTNAME CONTAINS "bed" AND PRICE_VAT < 4000
MERGADO 2: PRODUCTNAME CONTAINS "bed" AND PRICE_VAT < 4000
6) I am looking for a specific variant that contains the value “idvariant3” in the @id attribute of the <VARIANT>
element.
<VARIANTS>
<VARIANT id="idvariant3">
<CODE>EEQ21</CODE>
<UNIT>unit</UNIT>
<FREE_SHIPPING>1</FREE_SHIPPING>
<FREE_BILLING>1</FREE_BILLING>
MERGADO 1: you can’t simply
MERGADO 2: VARIANTS | VARIANT | @id ~ "idvariant3"
7) I am looking for a category with id 123
Electronics AppliancesMERGADO 1: DEFAULT_CATEGORY(id=123) - wrong entry towards XML
MERGADO 2: CATEGORIES | DEFAULT_CATEGORY | @id="123"
8) Loading multi-value elements in MERGADO 1 and 2:
<IMGURL>https://url1.com</IMGURL>
<IMGURL>https://url2.com</IMGURL>
MERGADO 1: incorrectly as element IMGURL
and IMGURL|1
MERGADO 2: you can target any element at any position in IMGURL { @@POSITION = 2 }
More information on how to work with multi-value elements: