# XML attribute – meaning and difference from an element

> An XML attribute is data written inside a tag in the form name="value". When feeds use attributes, how they differ from elements and what to watch out for.

Source: <https://sortyra.com/glossary/xml-attribute-in-feed>

---

[Sortyra](https://sortyra.com/) [Glossary](https://sortyra.com/glossary) [U – X](https://sortyra.com/glossary/u-x)

# XML attribute

Sortyra team · February 23, 2026 · 3 min read

[Glossary](https://sortyra.com/glossary)

[A – D](https://sortyra.com/glossary/a-d) [E – H](https://sortyra.com/glossary/e-h) [I – L](https://sortyra.com/glossary/i-l) [M – P](https://sortyra.com/glossary/m-p) [Q – T](https://sortyra.com/glossary/q-t) [U – X](https://sortyra.com/glossary/u-x)

- [Unmatched offer](https://sortyra.com/glossary/unmatched-offer-comparison-site)
- [URL](https://sortyra.com/glossary/what-is-a-url)
- [UTF-8 encoding](https://sortyra.com/glossary/utf-8-encoding-in-feed)
- [UTM parameters](https://sortyra.com/glossary/utm-parameters-in-links)
- [Value mapping table](https://sortyra.com/glossary/value-mapping-table-feed)
- [VAT in the feed](https://sortyra.com/glossary/vat-in-feed-price-and-rate)
- [Webhook](https://sortyra.com/glossary/what-is-a-webhook)
- [Webhook signature (HMAC)](https://sortyra.com/glossary/webhook-signature-hmac)
- [Wholesale](https://sortyra.com/glossary/wholesale-b2b-feed)
- [XLSX](https://sortyra.com/glossary/what-is-an-xlsx-file)
- [XML](https://sortyra.com/glossary/what-is-an-xml-file)
- [XML element](https://sortyra.com/glossary/xml-element)

An attribute is extra data written directly inside an element's opening tag, in the form name="value". While the element holds the main data, the attribute describes it in more detail – for example a gift's identifier or a parameter's unit. In product feeds attributes are less common than elements, but some formats rely on them.

**In this article**

1. What is an XML attribute
2. What it looks like in a feed
3. What it is used for
4. What to watch out for
5. How Sortyra helps
6. Related terms
7. Frequently asked questions

## What is an XML attribute

If an [element](https://sortyra.com/glossary/xml-element) is a drawer with a label, an attribute is a small note stuck on the label. It doesn't hold the main data but says something extra about it. It is written inside the opening tag: `<GIFT ID="DAR-01">`. Before the `=` sign is the attribute name, after it the value in quotation marks.

One element can have several attributes, but each with a different name. An attribute cannot contain further nested data – it is always just a short piece of text.

**Warning:** In its Merchant Center documentation, Google calls all product fields "attributes", for example `price` or `brand`. In the feed, however, they are elements. So the word "attribute" can mean two different things.

## What it looks like in a feed

`<!-- Heureka: a gift with its own ID in an attribute --> <GIFT ID="DAR-01">Free head torch</GIFT> <!-- Ceneo: the main offer data is in attributes --> <o id="STAN-204" price="129.90" url="https://www.sortyra.com/horal-trek-2-tent"> <name>Horal Trek 2 tent</name> </o>`

In the first line the gift is the element's text and its code is an attribute; the Polish comparison site Ceneo stores the code, price and link directly in attributes of the `o` tag.

## What it is used for

- **The feed header** – `version="2.0"` and `xmlns:g="…"` in the Google feed wrapper are attributes.
- **Additions to a value** – a gift code, a parameter's unit, the language of a text.
- **Whole offers** – some comparison sites and availability feeds (for example `<item id="STAN-204">` in Heureka's availability feed) carry the identifier in an attribute.

## What to watch out for

- **The value always in quotation marks.** `id=STAN-204` without quotes is an error and the file won't be read.
- **Special characters.** You can't use [CDATA](https://sortyra.com/glossary/cdata-in-xml-feed) in an attribute, so `&` and `"` must be written as `&amp;` and `&quot;` – typically in links with parameters.
- **Data hidden in an attribute.** If a supplier puts the price in an attribute, you won't find it in the element's text when mapping – you need to pick the attribute itself.
- **The same attribute twice** in one element is not allowed in XML.

## How Sortyra helps

When loading an XML source, Sortyra also takes attributes as separate fields (marked with `@`, for example `@id`), so in **Mapping** you assign them just like elements. Parameters written as `<param name="Colour">red</param>` are recognised as a name–value pair.

## Related terms

- [Element (tag)](https://sortyra.com/glossary/xml-element)
- [XML](https://sortyra.com/glossary/what-is-an-xml-file)
- [CDATA](https://sortyra.com/glossary/cdata-in-xml-feed)
- [Field mapping](https://sortyra.com/glossary/data-mapping)
- More detail: [Feed types](https://sortyra.com/knowledge-base/feed-types-xml-csv-json)

## Frequently asked questions

### What is the difference between an element and an attribute?

An element has an opening and a closing tag and can contain text as well as other elements. An attribute is a short piece of data in the form name="value" inside the opening tag.

### Why does Google talk about attributes when the feed has elements?

That is Google's name for product properties, regardless of how they are written. In an XML feed for Google, these "attributes" are written as elements, for example `<g:price>`.

[← Previous article **XML**](https://sortyra.com/glossary/what-is-an-xml-file) [Next article → **XML element**](https://sortyra.com/glossary/xml-element)

## Try it on your own feed

[Try it free](https://app.sortyra.com/registracia?lang=en) [Book a 15-min call](https://sortyra.com/contact)
