In XML, which attribute is used to uniquely identify an element?

2025

In XML, which attribute is used to uniquely identify an element?

  1. A.

    id

  2. B.

    class

  3. C.

    name

  4. D.

    tag

Attempted by 168 students.

Show answer & explanation

Correct answer: A

Concept: In XML an attribute name carries no built-in meaning on its own. XML’s standard ID machinery recognises an attribute as an element identifier in exactly two ways: a DTD or Schema declares it with the attribute type ID, or the author uses the W3C’s reserved xml:id attribute, which needs no declaration. (An individual application may impose conventions of its own, but those lie outside XML’s standard vocabulary.) Under either standard mechanism the name conventionally chosen for that identifying attribute is id — the convention HTML already follows, and the local name the W3C itself picked for xml:id.

Application: The stem asks which attribute identifies an element uniquely. That identifying role belongs to an attribute declared of type ID, or to xml:id — and the name conventionally carried by that attribute, under either mechanism, is id. None of class, name or tag is tied to the identifying role at all. So among the four names offered, id is the one the question is after.

Contrast — what each of the other three names actually is:

  • class — in raw XML simply an ordinary attribute name; the role it is remembered for comes from HTML and CSS, where a stylesheet rule matches its value to apply formatting.

  • name — likewise an ordinary XML attribute name; its familiar role comes from HTML forms, where the value becomes the control name in the name/value pair that the form submits.

  • tag — not a predefined attribute at all, but markup terminology: <employee> is a start-tag and employee is the element name it carries.

Note: Strictly, id="e101" in a bare XML document with no DTD, Schema or xml:id is just another attribute — the uniqueness guarantee comes from the ID-type declaration or from xml:id, not from the letters i-d themselves. This question tests that naming convention, and among id, class, name and tag only id is tied to the identifying role at all.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs

Loading lesson…