Skip to main content
XMLDir

Search 309 pages — tools, formats, elements, namespaces, directory, comparisons, XPath, datatypes, glossary, parse errors, schema errors, use cases, blog and product.

Document structure

Element

The unit of structure in XML: a start tag, its content, and a matching end tag — or a single self-closing tag when there is no content.

Elements nest strictly and never overlap. That single rule is most of what well-formedness means, and it is the one HTML habits break: a start tag opened inside a sibling must be closed inside it too.

An element's name is a QName, so it carries a namespace as well as a local name. Two elements written with identical tag text are different elements if the namespaces in scope differ.

Defined in
XML 1.0 §3
Category
Document structure
Also written
tag, node

Shown, not asserted

All 2 claims are executed on every test run, against the same engines the tools use. If the behaviour changes, the test fails rather than this page quietly becoming wrong.

  • Overlapping elements cannot form a tree, so the parser stops.

    document.xml
    <a><b></a></b>

    What the engine returns

    Opening and ending tag mismatch: b line 1 and a (line 1)
  • Element children are selected by name; text and comments are not elements.

    document.xml
    <r>text<a/><!-- c --><b/></r>
    expression
    count(/r/*)

    What the engine returns

    2

What catches people out

  • Element names are case-sensitive. <Item> and <item> are different elements, and closing one with the other is an error.
  • There is no void element in XML. <br> must be written <br/> or closed explicitly.
  • Order between siblings is part of the document; a schema that declares a sequence enforces it.

Get started

Bring order to the XML your team can't afford to ignore.

Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.