ConvertCSV

Common XML Errors and How to Fix Them

By Convert CSV Editorial TeamLast updated August 1, 2026

Fix common XML errors: mismatched tags, unescaped characters, namespaces, encoding, and schema failures. Diagnose fast with clear examples.

Three Buckets of XML Failure

Almost every XML ticket is well-formedness, encoding, or schema. Identify the bucket before you rewrite the file.

BucketSymptomFirst check
Well-formedParser throws / browser shows parsererrorxmllint --noout
EncodingMojibake or illegal character errorsfile encoding + declaration
SchemaParses but partner rejectsxmllint --schema

Well-Formed Errors

These stop the parser before any business logic runs.

Mismatched or overlapping tags

Tags must nest cleanly—no overlaps.

<!-- Bad -->
<item><name>Ada</item></name>

<!-- Good -->
<item><name>Ada</name></item>

Unescaped special characters

& and < in text are the classic breakers.

<!-- Bad -->
<company>Ada & Charles</company>

<!-- Good -->
<company>Ada &amp; Charles</company>

Unquoted attributes

Attribute values need quotes.

<!-- Bad -->
<item sku=A1 />

<!-- Good -->
<item sku="A1" />

Multiple roots

A document needs exactly one root element. Concatenated records without a wrapper are invalid.

Invalid element names

Names cannot contain spaces or start with a digit. CSV headers like "Order ID" or "1st_name" must be normalized before CSV → XML.

Encoding Errors

Bytes that look like garbage are usually encoding mismatches.

  • Declare encoding="UTF-8" and actually save as UTF-8.
  • Avoid a UTF-8 BOM unless a partner explicitly requires it.
  • "é" instead of "é" means UTF-8 was read as Latin-1/Windows-1252.
  • Strip illegal control characters that Excel sometimes embeds.

Namespace Errors

Empty query results after a "successful" parse often mean namespaces.

  • Default xmlns on the root changes every child’s expanded name.
  • Prefix without a binding is a well-formedness error.
  • Schema targetNamespace must match the instance document.
  • Copy-pasting samples from docs without the xmlns block fails XSD checks.

Schema Errors After CSV → XML

Generated feeds fail XSD for predictable reasons.

  • Wrong element order under xs:sequence.
  • "yes"/"no" where xs:boolean expects true/false.
  • Currency symbols or commas in xs:decimal fields.
  • Locale dates instead of xs:date (YYYY-MM-DD).
  • Extra columns that become unexpected elements.

Diagnostic Workflow

Work top to bottom.

  • Run xmllint --noout file.xml for well-formedness.
  • Confirm encoding with your editor or the file utility.
  • Run xmllint --schema schema.xsd file.xml when an XSD exists.
  • Flatten with XML to CSV to inspect values in a table.
  • Fix the CSV source and regenerate instead of endless hand edits.

Real-World Examples

Tickets you have probably seen.

"Opening and ending tag mismatch"

Usually a missing closing tag after a merge conflict or a bad template.

"Entity 'nbsp' not defined"

HTML entities are not valid in plain XML unless declared. Use &#160; or real Unicode.

Partner says "invalid amount"

Schema expects xs:decimal; the CSV still has "$1,200.00". Clean the column first.

Common Mistakes

Shortcuts that create more errors.

  • Editing XML in Excel and saving as something that is no longer XML.
  • Copying HTML into an XML template.
  • Suppressing parser errors and shipping anyway.
  • Fixing symptoms in the XML while the CSV pipeline keeps regenerating bad files.
  • Assuming "opens in browser" means schema-valid.

Best Practices

Prevent the next incident.

  • Validate in CI for every generated feed.
  • Escape text when building XML from strings.
  • Normalize CSV headers and types before conversion.
  • Keep sample good/bad files next to the XSD.
  • Prefer libraries over string concatenation.

Why Use Convert CSV Online?

Convert CSV Online is free, browser-based, and requires no account for everyday conversions. Inspect broken feeds via XML to CSV, fix columns in the Online CSV Editor, and regenerate with CSV to XML. Client-side workflows work on Windows, macOS, and Linux browsers.

See the data, not only the tags

Many "XML bugs" are dirty spreadsheet values. Tables make them obvious.

Conclusion

Most XML failures are mismatched tags, unescaped characters, encoding, namespaces, or schema type mismatches. Diagnose the bucket, fix the source, and validate before the next upload.

FAQ

What is the most common XML error?

Unescaped & characters and mismatched tags. Both break well-formedness and stop parsers immediately.

How do I fix "EntityRef: expecting ';'"?

You likely have a bare & in text. Replace it with &amp; or use a proper XML builder that escapes for you.

Why does my XML parse but the partner rejects it?

It is probably schema-invalid: wrong types, missing required fields, wrong namespace, or unexpected elements.

Why are my XPath queries empty?

Namespaces. Elements may live in a default xmlns. Query with the correct namespace URI or local-name strategies.

Can Excel create valid XML?

Not reliably for arbitrary schemas. Prefer CSV → XML with escaping and XSD validation.

How do I check XML quickly?

xmllint --noout file.xml for well-formedness; add --schema when you have an XSD.

References

Convert your CSV in the browser

Preview, clean, and convert CSV files free with Convert CSV Online—no installation and no account required for everyday conversions.