# The content of elements must consist of well-formed character data or markup

Source: https://xmlvalid.com/errors/content-of-elements-must-consist-of-well-formed-character-data

> A &lt; in text that does not start a valid tag.

The message, as Java reports it: `The content of elements must consist of well-formed character data or markup.`

## Why it happens

- A literal `<` in text, such as a comparison or code snippet.
- A tag name starting with a digit, a space or another character not allowed at the start of a name.

## How to fix it

- Write `&lt;` for a literal `<` in text, or wrap the text in a CDATA section; fix the tag name if it is meant to be one.
- Java's schema validation (`javax.xml.validation.Validator`, and JAXB or Spring on top of it) throws at the first error unless you set an `ErrorHandler` whose `error()` records the `SAXParseException` and carries on; each one has `getLineNumber()` and `getColumnNumber()`. A well-formedness error ends parsing whatever the handler does.

## The same problem in xmlvalid

libxml2, which xmlvalid validates with, reports it as [StartTag: invalid element name](https://xmlvalid.com/errors/starttag-invalid-element-name): `StartTag: invalid element name`

## Example that fails

```xml
<expr>a < b</expr>
```

## Fixed

```xml
<expr>a &lt; b</expr>
```
