# Is a duplicate attribute name

Source: https://xmlvalid.com/errors/is-a-duplicate-attribute-name

> The same attribute appears twice on one element.

The message, as .NET reports it: `'id' is a duplicate attribute name. Line 1, position 14.`

## Why it happens

- XML built by string concatenation that adds an attribute again, or a template that sets it twice.

## How to fix it

- Keep one occurrence of the attribute.
- .NET throws an `XmlSchemaValidationException` at the first schema error unless `XmlReaderSettings.ValidationEventHandler` is set, which then receives every one with its line and position. A well-formedness error is an `XmlException` and ends reading whatever the settings.

## The same problem in xmlvalid

libxml2, which xmlvalid validates with, reports it as [Attribute redefined](https://xmlvalid.com/errors/attribute-redefined): `Attribute id redefined`

## Example that fails

```xml
<item id="1" id="2"/>
```

## Fixed

```xml
<item id="1"/>
```
