Ffile2fix
Sign in Get started

What is a .xml file?

An .xml file is a text document that structures data with nested tags, defined by the W3C Extensible Markup Language standard. You meet it in sitemaps, RSS feeds, WordPress export files, SOAP APIs, Android layouts and Office documents.

Key facts

  • Must be well-formed: one root element, every tag closed, tags properly nested and attribute values quoted.
  • MIME type is application/xml (text/xml is also used); feeds and sitemaps often have more specific types.
  • The optional declaration <?xml version="1.0" encoding="UTF-8"?> must be the very first thing in the file.
  • Characters such as & and < must be escaped as &amp; and &lt; or placed in a CDATA section.
  • Structure can be validated against a DTD or XSD schema; parsers should disable external entities to avoid XXE attacks.

How to open a .xml file

Windows

Open it in VS Code or Notepad++ for editing, or drag it into a browser for a collapsible tree view.

macOS

Open it in a browser, TextEdit or a code editor, or run xmllint --format file.xml in Terminal (xmllint ships with macOS).

Linux

Run xmllint --noout file.xml to check it is well-formed and xmllint --format file.xml to pretty-print (package libxml2-utils on Debian/Ubuntu).

Common problems and fixes

"XML declaration allowed only at the start of the document"
Something precedes <?xml, often whitespace, a blank line or a byte-order mark added by PHP or an editor. Remove everything before the declaration and save as UTF-8 without BOM.
"Opening and ending tag mismatch" or "not well-formed"
A tag is not closed or is closed in the wrong order. Go to the line the parser reports and fix the nesting.
"EntityRef: expecting ';'" or errors at an ampersand
A raw & appears in text or a URL. Replace it with &amp;, or wrap the text in <![CDATA[ ... ]]>.
"Input is not proper UTF-8"
The file declares UTF-8 but contains Windows-1252 bytes. Convert it to real UTF-8 or change the declared encoding to match.
Sitemap or RSS feed rejected by Google or a reader
Check it is well-formed first, then confirm it uses the correct namespace and required elements. Search Console's sitemap report shows the specific error.

Often converted to or from: JSON, CSV, YAML, HTML

Frequently asked questions

Why does my XML open as plain text with no formatting?

The file is probably minified onto one line or has no stylesheet attached. Pretty-print it with an editor or xmllint --format to make it readable.

Is XML the same as HTML?

No. Both use tags, but HTML has a fixed vocabulary and forgiving parsing, while XML lets you define your own tags and must be strictly well-formed.

How do I open an XML file in Excel?

Use Data > Get Data > From File > From XML, or open the file and choose 'As an XML table'. Deeply nested XML may need flattening first.

See all file types β†’ Β· Browse error fixes β†’