XML Parsing Error: not well-formed: causes and fixes
TL;DR: Validate locally, fix the first real error, validate again (no upload).
Troubleshoot XML Parsing Error: not well-formed and fix invalid XML locally (no upload).
What the error means
XML Parsing Error: not well-formed means the XML parser found invalid markup. Most XML issues are fixable by correcting the first broken tag/character and re-validating.
Most common real-world causes
- The XML violates syntax rules (not well-formed) due to tags/escaping/structure issues.
- Mismatched tags (opening/closing tags do not match).
- Unescaped reserved characters (especially & in text).
- Multiple root elements (XML must have exactly one root).
- Invalid characters (control chars, bad Unicode) inside the file.
- Wrong encoding or a stray BOM/prolog mismatch.
- Cut/truncated XML (missing closing tags).
Fast debugging steps
- Check the first invalid character near the reported location; it is usually the true root cause.
- Validate the first error first. Fixing the first broken tag usually resolves many downstream errors.
- Search around the reported line/column for mismatched tags or a raw '&' that should be '&'.
- Confirm the XML starts with a single root and ends with the matching closing tag.
- If the file comes from a feed/export, try a smaller sample to isolate the first invalid record.
Code example (browser)
// Parse XML safely in the browser
const parser = new DOMParser();
const doc = parser.parseFromString(xmlText, 'application/xml');
// Most browsers emit <parsererror> on invalid XML
const errEl = doc.querySelector('parsererror');
if (errEl) throw new Error(errEl.textContent || 'Invalid XML');
// If valid: access doc.documentElement
console.log(doc.documentElement.nodeName);
Fix without uploading data
If the XML contains sensitive data, validate and convert locally. No Upload Tools runs 100% in your browser.
- XML to JSON to trigger strict parsing and see the first parser error.
- JSON Validator to validate output if you post-process to JSON.
Workflow: validate -> fix the first error -> validate again -> export/convert.
FAQ
Why do I get different errors in different tools? XML parsers differ. Always fix the first error in the raw input and re-check.
Should I regex-fix XML? Avoid blind regex edits. Validate after each change so you know what you fixed.
Related tools
Related guides
Privacy & Security
All processing happens locally in your browser. Files are never uploaded.
Related by intent
Closest pages and hubs to accelerate crawl discovery and first impressions.
First impression poolImpression seed hubIntent hub: troubleshootingTopic: xmlRelated: winner compare node csharp newtonsoft error converting infinity system int32 items 0 id reliabilRelated: winner rust jsonwebtoken jwt signature is required troubleshooting sdk integrationRelated: winner rust jsonwebtoken jwt signature is required troubleshooting webhooksRelated: winner rust jsonwebtoken jwt signature is required troubleshooting api gateway