Unquoted Attribute Values in XML
In XML, every attribute value must be enclosed in either double quotes or single quotes. Unlike HTML, which sometimes allows unquoted attribute values for simple strings, XML enforces quoting strictly. An unquoted attribute value makes the document not well-formed.
Why It Matters
The XML parser stops at the unquoted attribute and rejects the entire document. This is especially common when developers familiar with HTML write XML and forget that XML has stricter rules for attribute values.
Code Examples
<?xml version="1.0" encoding="UTF-8"?>
<products>
<product id=101 category=electronics>
<name lang=en>Laptop</name>
<price currency=USD>999</price>
</product>
</products><?xml version="1.0" encoding="UTF-8"?>
<products>
<product id="101" category="electronics">
<name lang="en">Laptop</name>
<price currency="USD">999</price>
</product>
</products>How to Fix
- 1Wrap every attribute value in double quotes: id="101" instead of id=101.
- 2You can also use single quotes: id='101'. Both are valid in XML.
- 3If the attribute value contains double quotes, wrap it in single quotes or use " entity.
- 4Run your XML through a validator to catch all unquoted attributes at once.
Check Your XML Now
Our XML validator detects this error automatically and shows the exact line and column.
Open XML ValidatorHostinger — Fast & Affordable Web Hosting
Serve well-formed XML feeds and APIs on reliable hosting.
Related XML Errors
Unescaped Special Characters in XML
Characters like &, <, and > must be escaped in XML text content. Learn how to fix unescaped character errors.
Mismatched Tags in XML
XML tag names are case-sensitive. Learn how to fix mismatched opening and closing tags in XML documents.
Invalid or Missing XML Declaration
Learn how to write a correct XML declaration and fix common mistakes like wrong attribute order or missing encoding.