# xmlParseEntityRef: no name

Source: https://xmlvalid.com/errors/xmlparseentityref-no-name

> A bare ampersand (&amp;) in text or an attribute.

Example message: `xmlParseEntityRef: no name`

## Why it happens

- Text such as *Smith &amp; Sons* or a URL with a query string (`?a=1&b=2`) written into XML without escaping.
- XML built by joining strings instead of with an XML library, which would have escaped it.

## How to fix it

- Write `&amp;` for every ampersand that is not the start of an entity. When the XML is generated by code, use a serializer or the language's escaping function rather than string concatenation; or wrap literal text in `<![CDATA[ … ]]>`.

## Example that fails

```xml
<company>Smith & Sons</company>
```

## Fixed

```xml
<company>Smith &amp; Sons</company>
```
