# '<', hexadecimal value 0x3C, is an invalid attribute character

Source: https://xmlvalid.com/errors/is-an-invalid-attribute-character

> A literal &lt; inside an attribute value.

The message, as .NET reports it: `'<', hexadecimal value 0x3C, is an invalid attribute character. Line 1, position 15.`

## Why it happens

- A comparison or HTML snippet written into an attribute as is, usually by string concatenation.

## How to fix it

- Write `&lt;` instead of `<`, or build the XML with `XmlWriter` or `XElement`, which escape it.
- .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 [Unescaped '<' not allowed in attributes values](https://xmlvalid.com/errors/unescaped-less-than-in-attribute): `Unescaped '<' not allowed in attributes values`

## Example that fails

```xml
<rule test="a < b"/>
```

## Fixed

```xml
<rule test="a &lt; b"/>
```
