# Element-Path

**URL:** <https://forum.mergado.com/t/element-path/753>\
**Category:** Elements\
**Tags:** mergado-2, elements, element-path\
**Created:** [May 23, 2023, 8:29am UTC](https://forum.mergado.com/t/element-path/753 "2023-05-23T08:29:12Z")\
**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 23, 2023, 8:29am UTC](https://forum.mergado.com/t/element-path/753/1 "2023-05-23T08:29:13Z")

</div>

In this post, we will learn:

- [What is Element-Path?](https://forum.mergado.com/t/element-path/753#what-is-element-path-1)
- [What is path to element?](https://forum.mergado.com/t/element-path/753#what-is-path-to-element-2)
- [How is the path to the element written?](https://forum.mergado.com/t/element-path/753#element-path-vocabulary-and-grammar-3)
- [Where do we use element paths?](https://forum.mergado.com/t/element-path/753#what-is-element-path-for-12)
- [Summary](https://forum.mergado.com/t/element-path/753#summary-15)

Mergado Editor [perceives elements](https://forum.mergado.com/t/elements/501#element-in-mergado-editor-4) in the same way as [XML feeds](https://forum.mergado.com/t/elements/501#element-in-xml-feed-2) do. This is the basis for all the [work with elements](https://forum.mergado.com/t/elements/501#working-with-elements-in-the-mergado-editor-6), where we encounter, for example, [nested](https://forum.mergado.com/t/nestedness/748) or [multi-value](https://forum.mergado.com/t/what-is-a-multi-value-element/589) elements. And to be able to modify specific [element values](https://forum.mergado.com/t/elements/501#element-in-xml-feed-2), we need to have **a way to target those values**. That’s what we have Element-Path for.

## What is Element-Path?

_Element-Path_ is **a language,** authored by us (Mergado), that we use to **write paths to elements** (and their values).

### What is path to element?

_A path to element_ is a **tool we use to target element values**. By targeting, we mean that we either want to take a value from an element and work with it somewhere else, or we want to write to it and modify it.

**Example** : if we want to target a product name (e.g. the value of the NAME element), the path would be “NAME”. The Mergado Editor [reads](https://forum.mergado.com/t/element-path/753#how-to-read-path-11) this path and knows which element to look at and what value to take/modify.

> ℹ &nbsp;In Mergado 1, the Element-Path language could not be used, as there were no multi-value elements or [element structure](https://forum.mergado.com/t/elements/501#element-in-mergado-editor-4) in that version.

## Element-Path vocabulary and grammar

Since Element-Path is a language, Element-Path, like regular languages, has a vocabulary (the elements that can be used in paths to elements) and a grammar (a set of rules for how paths are written).

**Example** : if we compare the Element-Path language to English, then a path to an element is analogous to a sentence:

- Different _sentences_ with different content use the words and grammar of the _English_ language.
- Different _paths to different elements_ use the words and grammar of the _Element-Path_ language.

### The names of all the elements

The Element-Path vocabulary includes the names of all elements. The simplest path is one that consists of the name of the element itself.

**Example** : you may have used the [Rewrite](https://forum.mergado.com/t/rewrite/491) rule to edit a product description, i.e. you have overridden the value of the DESCRIPTION element. This means that you have entered the text “DESCRIPTION” in the field for the element.

![](https://lh6.googleusercontent.com/TNNeMsDNBBieNprBZoqFAKVTeQCvkX494rwNdgFY6DZZY1hNKZuGTOm0EJ1OvxIlOfWjDnZVjwzRKU990ECI7j0v1E_5I-4LaomOHsRblfExk9y_pwn8eCalkZtyMYko-EGwEJWAYjQHMCChK5XyagM)

### Nestedness

If you want to target a [nested](https://forum.mergado.com/t/nestedness/748) element **add the element’s [parent](https://forum.mergado.com/t/nestedness/748#children-and-parents-4) name and the [vertical bar](https://en.wikipedia.org/wiki/Vertical_bar) |** (another addition to the vocabulary) **to the path before the element**.

**Example** : we want to target the information parameter - the NAME element nested under the INFORMATION\_PARAMETER element.

![image](https://forum.mergado.com/uploads/default/original/1X/db97978d229b47a5b91dd73df019964c9d0a3377.png)

Since the NAME element for the information parameter is nested under the INFORMATION\_PARAMETER element (which is nested under INFORMATION\_PARAMETERS), the path to its values looks like this:

![image](https://forum.mergado.com/uploads/default/original/1X/1aae0a4c9623b259a0ab37414c55fa79754bf8bc.png)

The Mergado Editor [reads](https://forum.mergado.com/t/element-path/753#how-to-read-path-11) the path by first going to the INFORMATION\_PARAMETERS element, then to its [children](https://forum.mergado.com/t/nestedness/748#children-and-parents-4), where it overwrites the value of the NAME element within the INFORMATION\_PARAMETER element.

### Conditions

The conditions in the element path are a filter that allows us to **filter values for [multi-value](https://forum.mergado.com/t/what-is-a-multi-value-element/589) elements** within the path. They are written in [curly brackets](https://en.wikipedia.org/wiki/Bracket) { }. Conditions are an important part of Element-Path, so we recommend you [read the detailed post on conditions in element paths](https://forum.mergado.com/t/conditions-in-the-element-path/757).

**Example:** We want to modify the value of the Material information parameter.

 ![image](https://forum.mergado.com/uploads/default/original/1X/db510504a77c5d783faa93ba3c15845b9b8dc989.png)

This is a nested VALUE element and the path looks like this:

![](https://lh3.googleusercontent.com/DdtNB6_i7ATqBJB-z2EtocS0_ApUQI7rlCqRwPsMp2cvzd7PYC_cdiWksGnrfzGQ0t_CFZv9Wc37fnndiV6QJqnd7nCJxWF6PCuizFjLJE2XDqE0E_Ca8CbBUutP9PUwIL0FBmfUzaHBn3qupbyKnQM)

Except that the path targets all values of the VALUE element

 ![image](https://forum.mergado.com/uploads/default/original/1X/358690a37ba49ba640d7210229e82d0d26364f17.png)

and we only want to modify the value for Material. We will therefore use the condition. The **final path** will therefore be:

![](https://lh4.googleusercontent.com/LH7pkA4koevh08e8waZLlKoBAFlzfIiFWG2sgfLXVE-92B_sVSscqEKu0QWolpjPv51W7h8c_X2vHSIBnvFHleXdKKiCDNC8tii-nTCUVlUG8L_R_3htIqa6uVEMkwURDVKd0c24UguM61DSGvVKq-A)

 ![image](https://forum.mergado.com/uploads/default/original/1X/16de405f7b31fd934e374496c510f20b5790bc91.png)

### Special attributes

There are [special attributes](https://forum.mergado.com/t/special-attributes/749) [@@POSITION](https://forum.mergado.com/t/position/766) and [@@VALUE](https://forum.mergado.com/t/value/751). These attributes can be used in conditions. You can read more about them in the individual posts.

**Example:** `IMGURL_ALTERNATIVE { @@POSITION >= 2 }`

**Example:** `CATEGORIES | CATEGORY { @@VALUE != "Toys" }`

> 💡 If you can think of another special attribute you would use, [email us](mailto:mergado@mergado.cz)!

### MQL in Element-Path

We don’t stop at special attributes. In fact, we can type anything into conditions that we can type into [MQL query](https://forum.mergado.com/t/advanced-search/474). This adds the entire vocabulary of [MQL](https://forum.mergado.com/t/mql-language/755) to the Element-Path vocabulary. Again, we recommend [reading the detailed post on element path conditions](https://forum.mergado.com/t/conditions-in-the-element-path/757).

**Example:**  
`VARIANTS | VARIANT { PARAMETERS | PARAMETER { NAME = "Size" } | VALUE = "M" AND PARAMETERS | PARAMETER { NAME = "Material" } | VALUE = "Cotton" } | STOCK | WAREHOUSES | WAREHOUSE | NAME`

### Syntax errors

Just as you can make spelling or grammatical errors in English, you can make [syntax](https://en.wikipedia.org/wiki/Syntax) errors in Element-Path. If we make a syntax error in our writing, Mergado Editor usually warns us about it. As an example: omission of closing quotation marks in [condition in path to element](https://forum.mergado.com/t/conditions-in-the-element-path/757):

 ![image](https://forum.mergado.com/uploads/default/original/1X/5062c4f60fa6e4a99d38f7622bda2bdac5091cf2.png)

> 💡 Read the [post dedicated to errors in paths to elements](https://forum.mergado.com/t/errors-in-element-path-or-mql/771).

### The path to element or to values?

Throughout this post we write _path to element_, but you may have come across _path to element value_ or **similar other forms**. All of these shapes **are fine**. There are no rules about writing paths - it always depends on the writer’s judgement and the context of the whole text.

In general, the form _path to the value of the element_, i.e. with the word _value_, is more accurate because **path targets the value of the element, not the element itself**.

However, if we talk about **simple elements** , the _path to element_ form is clear enough, since **the element has only one value**. So we know that the path targets that one value. But if we talk about multi-value elements that have multiple values, it is more appropriate and accurate to use the form with the word _value_ if the path targets only one specific value.

Here are **some examples** :

- element/attribute path,
- element/attribute,
- IMGURL element,
- IMGURL element path,
- path to value 69 of PRICE\_VAT element,
- path to parameter value,
- path for element,
- element path,
- element whose path,
- value whose path,
- for value 69 the path is,
- path
- and many others.

### How to read path?

The rules for reading paths to elements are not explicitly given, but we recommend **following these principles** to better understand how the paths themselves work, i.e. what values they target in the result of the path.

**Principles of path reading:**

1. Read sequentially from left to right.
2. We read element names and special attributes intuitively as they come to us. E.g. “element ITEM\_ID” or just “ITEM\_ID” etc.
3. For unnested elements, just read “target the element” (or target the element value or all element values).
4. For paths with nested elements, start with “take” or another synonym.
5. We read vertical bars as “and the nested element under it” or “and its child”, etc.
6. For the last nested element, we say “and (in such an element) target the nested element under it” or “and (in such an element) target its child”, etc.
7. Conditions: we read the left curly bracket as “whose underlying nested element” or “whose child”, etc.

**Example 1:** `ITEM_ID`  
“We are targeting the ITEM\_ID element.”

**Example 2:** `INFORMATION_PARAMETERS | INFORMATION_PARAMETER { NAME = "Material" } | VALUE`  
We can read it like this:

- “Take an INFORMATION\_PARAMETERS element and an INFORMATION\_PARAMETER element nested under it, whose NAME element nested under it has a value equal to Material, and in such INFORMATION\_PARAMETER element target the VALUE element nested under it.”
- “Take INFORMATION\_PARAMETERS and its child INFORMATION\_PARAMETER whose child NAME has a value equal to Material, and in such INFORMATION\_PARAMETER target its child VALUE.”
- etc.  
 ![ezgif.com-gif-maker](https://forum.mergado.com/uploads/default/original/1X/e5baf07797fc90c0214b66c1af85a4bbd526bd87.gif)

**Example 3:** `CATEGORIES | CATEGORY { @@VALUE != "Toys" }`  
Let’s read it, for example, as follows:

- “We take the CATEGORIES element and target its CATEGORY child whose value is not equal to Toys.”
- “We take the CATEGORIES and target the submerged CATEGORY under, whose value is not equal to the Toy.”

## What is Element-Path for?

Element-Path is used to **write paths to elements** , which we then use to target element values.

### Where do we target element values?

We will use targeting element values (thus also Element-Path) **when working in the Mergado Editor** in many places, in general **everywhere we [work with elements](https://forum.mergado.com/t/elements/501#working-with-elements-in-the-mergado-editor-6)**:

1. In a simple **selection form - [Oneliner](https://forum.mergado.com/t/simple-search/473)** - on the [Products page](https://forum.mergado.com/t/mergado-2-the-products-page/587) when creating conditions. [In the first or third part of the condition](https://forum.mergado.com/t/mql-language/755#the-condition-consists-of-3-parts-5) it is possible to write paths to elements.  
&nbsp;  

2. In the [form for your own MQL query](https://forum.mergado.com/t/advanced-search/474).  
&nbsp;  

3. When **sorting products** on the Products page.  
&nbsp;  
 ![Snímek obrazovky z 2023-05-22 14-18-24](https://forum.mergado.com/uploads/default/optimized/1X/c1bbf2a41a400c7761b94445a5cc6791e935030a_2_690x40.png)

4. In the [table view](https://forum.mergado.com/t/mergado-2-the-products-page/587#woman_teacher20x20httpslh5googleusercontentcomr31jvjkvejubeua9m6nz3auahyq_mmorwo8p54z-e_qmesopalssrxtfxi4puc4yjd_w9zbsawjyqwvkeruuf69lz51zv9vmtgv0vwkhw4poh5ou8pllzwfpkvyzrs3omfvmhlxqs_bs2t-hhlixm7d-26c0hlx584itimxdk3k2a1-dzgvrfhopaq-woman_teacher-2-table-view-4) products when adding columns.  
  
 

5. In the **form of some rules in the field for the element** – refers to the rules Rewrite, Find and Replace, Bulk rewriting by query, Bulk rewriting by values, Bulk copy values, Truncate value, Letter case converter, Round number, Remove diacritics , Set UTM parameters, Remove HTML tags, Calculation and Add a value to a multi-value element.  
  
  ![image](https://forum.mergado.com/uploads/default/original/1X/6443cfcb2c63985d2a714b3e8fcd99b075ec5d6c.png)

6. In the **headers of import files** , which we upload via the [rule Data file import](https://forum.mergado.com/t/data-file-import/476).  
  
  ![pasted image](https://forum.mergado.com/uploads/default/original/1X/f3c13c3ababe26ddd9ba83157b61798b2a006997.png)

7. On the **page of the values of a specific element** (after clicking on the [Elements page](https://forum.mergado.com/t/mergado-2-elements/586)).  
  
 

8. When creating and editing **[variables](https://forum.mergado.com/t/variables/506)**.  
  
 

### Examples of targeting

We covered dozens of examples of targeting for different formats in a separate post [Element-Path: Examples of targeting (Heureka, Google, Shoptet)](https://forum.mergado.com/t/element-path-targeting-examples-heureka-google-shoptet/754).

## Summary

- [What is Element-Path?](https://forum.mergado.com/t/element-path/753#what-is-element-path-1)  
Element-Path is a language used to write paths to elements.  
&nbsp;
- [What is the path to the element?](https://forum.mergado.com/t/element-path/753#what-is-path-to-element-2)  
An element path is a tool we use to target element values.  
&nbsp;
- [How is the path to the element written?](https://forum.mergado.com/t/element-path/753#element-path-vocabulary-and-grammar-3)
  - We can write element names in the path.
  - Immersion is indicated by a vertical bar.
  - To specify the path, use conditions that are written in braces.  
&nbsp;

- [Where do we use element paths?](https://forum.mergado.com/t/element-path/753#what-is-element-path-for-12)  
We will use paths almost throughout the Mergado Editor, in short, everywhere we work and target elements and their values.
