</>
ValidateHTML

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

Invalid XML
<?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>
Valid XML
<?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 &quot; 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 Validator
Recommended

Hostinger Fast & Affordable Web Hosting

Serve well-formed XML feeds and APIs on reliable hosting.

Get 80% Off Hosting →

Related XML Errors

View all XML errors