LOGBOOK

HELP

Quiz Entry - updated: 2026.11.01

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

An element is the content from start-tag to end-tag (including everything nested inside); an attribute is a named key="value" pair written inside the start-tag that annotates the element.

The two are XML's two places to put data, and they look different:

<book isbn="1575213966">        <!-- isbn is an ATTRIBUTE of <book> -->
  <title>XML in 21 Days</title> <!-- <title> is a child ELEMENT; its text is the value -->
</book>
  • An element is the whole span <m1>…</m1> — the tags plus all text and sub-elements between them. Elements nest, so they carry the document's tree structure.
  • An attribute extends an element with extra metadata: <m1 attribute1="wert">element</m1>. Attributes live inside the start-tag, their values must be quoted, and they cannot nest or repeat within one element.

A useful rule of thumb for which to choose: the data itself goes in elements (it may need structure or several values later); small metadata about the data — an id, a unit, a language code — fits an attribute. This is also a real JSON difference: JSON has no attribute concept at all, only nested values, so converting attribute-heavy XML to JSON forces a remodel.

Tip: Quoted-ness is a quick syntax check — attribute values are always quoted (id="123"), element content never needs to be.

Go deeper:

From Quiz: WEBT / External Webservices | Updated: Nov 01, 2026