# Is an unexpected token. The expected token is

Source: https://xmlvalid.com/errors/is-an-unexpected-token

> The parser found a character where XML syntax requires a specific one, most often a quote or an equals sign.

The message, as .NET reports it: `'2' is an unexpected token. The expected token is '"' or '''. Line 1, position 11.`

## Why it happens

- An attribute value without quotes (`qty=2`): the expected token is a quote.
- An attribute without a value (`<input disabled/>`): the expected token is `=`.
- A typographic quote (`“`) instead of a straight one.

## How to fix it

- Write every attribute as `name="value"` with straight quotes.
- .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 [AttValue: " or ' expected](https://xmlvalid.com/errors/attvalue-quote-expected): `AttValue: " or ' expected`

## Example that fails

```xml
<item qty=2/>
```

## Fixed

```xml
<item qty="2"/>
```
