XML error · attribute
Attribute redefined
The same attribute name appears twice on one element, which XML forbids outright. HTML silently keeps the first; XML refuses the document.
Attribute href redefined (line 1)What it means
An element may not carry the same attribute name twice. HTML silently keeps the first; XML treats it as a well-formedness error and refuses the document.
In namespaced documents the rule applies after prefix resolution, so two different prefixes bound to the same URI count as a duplicate even though the text differs.
What usually causes it
- A merge that applied the same attribute from two sources.
- A template that adds a default attribute and then adds it again conditionally.
- Two prefixes bound to one namespace URI, colliding after resolution.
- Hand-editing that duplicated an attribute rather than replacing it.
How to fix it
- Remove the duplicate, deciding deliberately which value wins.
- Build attributes in a map keyed by expanded name so collisions are impossible.
- Check for two prefixes bound to the same namespace URI.
The same error elsewhere
Different parsers, same defect. If you arrived with one of these messages, you are in the right place.
Xerces (Java)
Attribute "href" was already specified for element "link".expat (Python)
duplicate attribute: line 1, column 44.NET System.Xml
'href' is a duplicate attribute name.
Before and after
Both snippets are re-checked by the test suite against the real parser: the first is confirmed to produce the exact error above, the second to parse cleanly.
<link rel="alternate" href="https://example.com/a" href="https://example.com/b"/><link rel="alternate" href="https://example.com/b"/>Where this bites most
Other XML errors
- Opening and ending tag mismatch
- Premature end of data in tag
- Extra content at the end of the document
- Unescaped ampersand (EntityRef: expecting ';')
- Entity is not defined
- Start tag expected
- XML declaration allowed only at the start of the document
- Unquoted attribute value (AttValue expected)
- Attributes construct error (unterminated quote)
- Invalid element name
- Document is empty
- Unsupported encoding
- Sequence ']]>' not allowed in content
- Comment not terminated
- Detected an entity reference loop
- PCDATA invalid Char value (control character)
- Unescaped '<' in an attribute value
- Invalid numeric character reference
- Blank needed here
- Malformed declaration expecting version
- Unsupported XML version
- Processing instruction not terminated
- CData section not finished
- Error parsing attribute name
- Double hyphen within comment
- CharRef: invalid decimal value
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.