By Feedlinter
XML Parsing Error: EntityRef: expecting ';' in Google Merchant Feed
Fix XML Parsing Error: EntityRef: expecting ';' in a Google Merchant feed. Learn why ampersands break XML and how to escape product titles, URLs, and text safely.
What the EntityRef error means
The parser has found an ampersand that looks like the start of an XML entity, but it cannot find a valid entity name followed by a semicolon. A product title such as `Salt & Pepper Set` is valid human text, but a raw ampersand is not valid inside XML content.
The same problem can appear in descriptions, brand names, URLs, custom labels, or attributes. One malformed character can make the entire XML document unreadable, so Google Merchant Center may reject the feed before it can evaluate individual products.
Escape special characters correctly
In XML text, write an ampersand as `&`, less-than as `<`, and greater-than as `>` when needed. For example, `Salt & Pepper Set` is valid XML and displays to shoppers as `Salt & Pepper Set` after parsing.
In a URL query string, each ampersand that separates parameters also needs XML escaping when placed inside an XML element. Keep the actual destination URL intact after parsing. Do not replace the ampersand with the letters `and`, because that changes the product name or link.
Use an XML serializer instead of manual replacement
The safest fix is to generate the feed with an XML library that escapes text and attribute values. Avoid building XML by concatenating raw product fields into strings. A serializer will also handle quotation marks and characters that have special meaning in XML attributes.
Do not escape the entire finished XML file after generation. That can turn valid markup such as `<g:title>` into visible text or double-escape entities such as `&` into `&amp;`. Escape each value once, at the point where it enters the XML document.
How to find the broken value
Run the generated file through an XML parser or validator and note the reported line and column. Open that part of the feed and look just before the parser position for a raw ampersand, malformed entity, or truncated product value. If the feed is one long line, pretty-print a copy for diagnosis without changing the submitted source.
Search the source catalog for the affected title or URL. Correct the data if the ampersand was accidental, then fix the generator so the same issue cannot return in another product. Validate the final XML after every export.
Prevent the next feed failure
Include product names with ampersands, quotation marks, accented characters, and query-string URLs in feed-generation tests. Confirm the feed is complete, parses successfully, and contains the expected product count before submitting it to Merchant Center.
The root cause is usually unsafe XML generation, not a Google policy issue. Correct escaping at the source and the EntityRef error disappears without changing the visible product text.