What is a .XML file?
A file with the .XML format is typically a W3C Extensible Markup Language file, a hierarchical text-based tree containing structured self-describing information. W3C launched XML format in 1998 and the file extension does not mean anything particular as regards vocabulary as a .xml file uses any XML language depending on the root element, namespace URI, the presence of a DOCTYPE or MIME type in it.
Some files ending in .xml format are:
Configuration files; Data export files; API payloads; Manifest files; Build files; Web feeds;
Sitemaps and others. For instance, RSS feeds usually start with "<rss version="2.0">" or "<rdf:RDF>" while feeds following the Atom format start with the "<feed xmlns='http://www.w3.org/2005/Atom'>". Both formats are used to distribute web content. While Microsoft Office 2003 XML and Excel XML Spreadsheet 2003 are single XML office documents, modern extensions use ZIP-based archives, for instance, .docx, .xlsx and .pptx files. Files for building UIs of Android applications can be seen in various locations such as res/layout, res/values, AndroidManifest.xml, etc.
Other kinds of XML formats which could use .xml files as an appropriate file extension include GraphML graph file format; MusicXML music score exchange format; XBRL Business reporting formats and others.
How to open a .XML file
Open a .XML file on Windows
- 1 Go to the folder with your file in File Explorer. Usually, downloaded files end up in Downloads.
- 2 Double-click your .XML file if you have an app for .xml files on your computer. In case it does not open, move on to step three.
- 3 Right-click your .XML file -> select .
- 4 Choose Visual Studio Code in the list (Windows 11: choose Always). For Windows 10 -> put a check on "Always use this app to open .xml files" and click OK.
Still not opening? See common problems and fixes, or view it in your browser.
Programs for Windows
- Visual Studio Code free
- Notepad++ open-source
- Oxygen XML Editor paid
- BaseX open-source
- Mozilla Firefox open-source
- Google Chrome free
- Saxon-HE open-source
- Microsoft Excel paid
Open a .XML file on macOS
- 1 In the Finder app, locate your .XML file.
- 2 Just double-click your .XML file in order to automatically launch the program which is connected with it.
- 3 Need another app on your Mac? Control-click the file (or right-click with a mouse). In the pop-up menu select .
- 4 If it isn't in the list, choose and find the application manually.
Still not opening? See common problems and fixes, or view it in your browser.
Programs for macOS
- Visual Studio Code free
- Oxygen XML Editor paid
- BaseX open-source
- Mozilla Firefox open-source
- Google Chrome free
- Saxon-HE open-source
- Microsoft Excel paid
- LibreOffice open-source
Open a .XML file on Linux
- 1 Launch your file manager. Depending on the desktop it may be named Files (GNOME), Dolphin (KDE Plasma), Nemo (Cinnamon) or Thunar (Xfce).
- 2 Double-click the file.
- 3 Or choose another program by right-clicking the file -> .
- 4 Install Visual Studio Code (if it is not installed on your computer) from the software centre, repository or Flathub.
Still not opening? See common problems and fixes, or view it in your browser.
Programs for Linux
- Visual Studio Code free
- Oxygen XML Editor paid
- BaseX open-source
- Mozilla Firefox open-source
- Google Chrome free
- Saxon-HE open-source
- LibreOffice open-source
- Android Studio free
Open a .XML file on Android
- 1 Launch Files or another file management app.
- 2 In Downloads, find the .XML file and open it by tapping.
- 3 A list of apps capable of opening the file will be shown. Tap Mozilla Firefox and press Always to permanently connect the file type with this app.
- 4 No apps able to open this file? Download Mozilla Firefox from the Google Play Store.
Still not opening? See common problems and fixes, or view it in your browser.
Programs for Android
- Mozilla Firefox open-source
- Google Chrome free
- Microsoft Excel paid
- Feedly freemium
Open a .XML file on iPhone / iPad
- 1 Use the Files app and go to On My iPhone, iCloud Drive or Downloads.
- 2 Tap the .XML file you want to open.
- 3 If the file can be opened by a built-in iOS app (supported format), it opens automatically.
- 4 Touch and hold the file to get the context menu -> choose -> select Mozilla Firefox from the list of apps.
- 5 If there is no such option, download the app first from the App Store and then tap the document again.
Still not opening? See common problems and fixes, or view it in your browser.
Programs for iPhone / iPad
- Mozilla Firefox open-source
- Google Chrome free
- Microsoft Excel paid
- Feedly freemium
Open a .XML file online
- 1 Move to the online viewer at the top of this page.
- 2 Drag the file there or select it, and its contents will appear in your browser tab. The file is not uploaded.
Still not opening? See common problems and fixes, or view it in your browser.
Programs for Online
- Visual Studio Code free
- Microsoft Excel paid
- Feedly freemium
More details about opening .XML files
Under Windows, working with the .xml format will require launching Visual Studio Code, or Notepad++ (for pure text editing), Oxygen XML Editor (for DTD and/or schema validation) and a browser in case only viewing purposes are needed. Microsoft Excel will open .xml with spreadsheets; LibreOffice opens various kinds of office XMLs and tabular exports, while Android Studio will be the best for Android resource .xml files; yEd will work better with GraphML format; MusicXML scores will open in MuseScore, and Arelle will handle XBRL instance files. In order, Visual Studio Code and Notepad++ will be free tools, while Oxygen will cost some money, while the remaining software differs by editions. Should double clicking trigger an error and open a wrong software application, try using "open with", reassign the file associations to .xml, or open the software in advance, and then press .
On Mac OS you will have available TextEdit to open small XML documents; XCode to edit Property List documents and XML-based project data; Safari (browser), Firefox and Chrome will be able to display well-formed XML, Oxygen XML and VS Code may handle any checking or editing of XML documents. Additional available packages: LibreOffice, Microsoft Excel, yEd, MuseScore and Arelle.
For your work under Linux you will need such useful software as GNOME Text Editor and Kate or VS Code, Vim, Emacs, LibreOffice, baseX, xmlStarlet, MuseScore, yEd, Arelle. Under consideration all mentioned software but few will cost you nothing, while for large files, avoid opening the document with any simplistic editor which loads it fully into the memory. Try instead such options as using special "large files mode" in Oxygen XML, or less, stream-based checks from xmllint command line utility, or BaseX, and/or a database imports utilities.
In Android/iOS systems browser applications and text editors will do just fine for looking at the .xml format, whereas Feedly should be able to open XML RSS and/or ATOM. Under the Web, for specific XML dialects you might need such sources as: Github, GitLab websites; online browser viewsers and validators; Feedly, online versions of Microsoft Office.
Never suppose the fact the file with .xml ending has actually anything to do with Word or Excel file; instead look at root element.
Technical details
XML is a text format, typically encoded in Unicode. Version of the XML document can be specified by declaring version="1.0" or version="1.1", and an encoding can be declared (e.g., "UTF-8", "UTF-16", or any registered charset). There is no magic number that would specify vocabulary. While most of the files start with ASCII byte sequence 3C 3F 78 6D 6C (which spells out "<?xml"), a valid document can begin with whitespaces, a byte order mark, a comment, or lack of XML declaration. For UTF-8 encoding sequence EF BB BF marks the file beginning, FF FE - for UTF-16LE, and FE FF - for UTF-16BE (this information does not say anything about file type).
Requirements for a well-formed XML document are an existence of exactly one document element, proper nesting of tags, quoted attributes, escaping of reserved characters like < and &, and inclusion only of characters in the specified XML ranges. Namespaces typically are declared using xmlns attributes and assign URI-qualified names which allows vocabularies like Atom, XBRL, Office XML to coexist in one file without name clashes for elements. In addition to well-formed document, it is possible to validate a document against DTD, W3C XML Schema .xsd file, RELAX NG, Schematron, or rules imposed by an application. XML also contains comments, processing instructions, CDATA sections, entity references, element content, attributes, and, if parser supports them, external references.
Size of the file can vary from a few hundreds bytes for configuration files to several gigabytes for logs, dumps, XBRL submissions, databases dump. It is very verbose but compresses well in ZIP containers and other compression schemes. XML 1.0 and XML 1.1 specifications were published by W3C with current versions being XML 1.0 Fifth Edition and XML 1.1 Second Edition respectively. Typical MIME types used are application/xml, text/xml, application/rss+xml, application/atom+xml, application/graphml+xml, application/vnd.recordare.musicxml+xml, application/x-plist.
How to convert .XML files
Translate XML to JSON in cases when the destination system will be a web API and or JavaScript applications.
Programs like xml-to-json, or command line utilities xq or yq offer simple translations:
Example:xq -o=json . input.xml >output.json. Yet attributes handling, repeating elements, namespaces and mixed content require mappings that have to be coded manually in Python, Node.js or other programs of similar nature.
There’s no one-to-one mapping in XML-to-JSON case, therefore comments and processing instructions usually disappear in the process.
Use XML-to-CSV conversion when the source document describes a tabular form of repeating records.
Various tools (xmlstarlet, XML/XSLT translators, XML/SQL converters, etc.) will flatten rows of data. Example:
xmlstarlet sel -t -m '//row' -v 'field1' -o ',' -v 'field2' -n input.xml > output.csv. It should be noted that in the resulting data hierarchy level won’t be preserved. Use XSLT processors or any application’s exporters to create HTML reports and manuals.
XML formats like SpreadsheetML are supported by Excel (convertible to .xlsx format) or LibreOffice (convertible to .ods format). Yet in general there's the need to have an import format defined or to use a custom column mapping. Together with XSL FO files XML could be translated to PDFs by means of Apache FOP processor. The list of conversions from XML-based files created by certain applications (Apple property lists, music notations - in XML file format .xml etc.) to native formats (.plist or .mxl, MIDI, pdf and musical sheets) could be performed by means of application specific tools. Some information (order and number of elements, namespaces, significant spaces, type information and signature data) may disappear after such conversions as usual.
| Convert to | Tool | Command / note |
|---|---|---|
| JSON | xq / yq | xq -o=json . input.xml > output.json Best for data-oriented XML; attributes, namespaces, mixed text, comments, and repeated elements may need custom mapping. |
| HTML | Saxon-HE XSLT processor | java -jar saxon-he.jar -s:input.xml -xsl:stylesheet.xsl -o:output.html Requires an XSLT stylesheet; preserves only data selected by the stylesheet. |
| CSV | xmlstarlet | xmlstarlet sel -t -m '//row' -v 'field1' -o ',' -v 'field2' -n input.xml > output.csv Useful for regular record-like XML; hierarchy, attributes, and nested repeating fields are flattened or discarded. |
| XLSX | LibreOffice headless | libreoffice --headless --convert-to xlsx input.xml --outdir out Works for spreadsheet-shaped XML such as Microsoft Office XML or importable tables; generic XML may require an import filter or schema. |
| Apache FOP | fop input.fo output.pdf XML must first be XSL-FO or transformed to XSL-FO; PDF is fixed-layout and not a faithful editable XML representation. |
|
| Binary property list | plutil | plutil -convert binary1 file.xml -o file.plist Applies to Apple XML property lists only, not arbitrary XML documents. |
| Compressed MusicXML | MuseScore Studio | Open a MusicXML .xml score in MuseScore and export .mxl to reduce size; score semantics are retained but application-specific engraving may change. |
Common problems and fixes
In some instances, such errors might be generated as messages from the browsers such as Mozilla Firefox and Google Chrome. Some messages include "This page contains the following errors," and "XML Parsing Error." It's essential first to edit the file content via VS Code, Notepad++ or oxygen XML Editor and re-parse the particular issue in reference with the specific line number and column.
The message "Content is not allowed in prolog" means the presence of strange content in prolog, hidden characters after copying content from other sources, wrong UTF-8 BOM encoding and whitespaces before XML declaration. Resave the file in proper XML encoding, remove any characters before "<?xml", and make sure any extra character doesn't enter to XML file during the cut and paste process especially when copying from emails. "Premature end of file" suggests the failure of saving or copying files due to truncating. Check your current files with the original files and compare sizes and resend them in binary mode of sending.
"Reference to undeclared entity" means usage of undefined entities within XML files in case the only valid entities for such type files are only amp, lt, gt, apos and quot but no declaration of document type is present. Substitute the undefined entity or add a document type declaration into the file. When getting the message of "The prefix ... is not bound" that means that a namespace prefix lacks an xmlns declaration in scope. You have to add the missing URI of namespace in XML file.
Microsoft Excel can give out "The specified XML source does not refer to a schema" or collapse everything into one table. Give an Xsd mapping to the file to solve these problems or choose a proper Office XML file to open it. Huge-sized files lead the editors to freezing; try to break down huge files or use such databases as BaseX, eXist-db and parse the file using SAX and Stax parsing. There're many reasons for incorrect file association because there're many types of documents under this file association (.xml).
Security considerations
However, while being unable by itself to be executed in any way, parsers or host applications become exposed to possible exploitation in certain cases. Disallow usage of the document type definitions and resolution of the entity references as the possible attack is based on them reading local system files or making network requests. Place the restrictions on the usage of entity or depths of the recursion to limit attacks like "billion laughs attack" or deeply nested elements as they can overload either your memory or CPU.
The SVG file, XHTML files or any content with Office XML, if parsed with a browser or some office product, can run script. Metadata in the XML file can disclose usernames, file names, version numbers of the software, file timestamping, databases name used, or even some comments, internal URLs, tracking data. Parse the input with secure parser library. Avoid opening any file you're not sure about in enterprise applications with privilege level high enough. Parse and verify signatures in XML.
History and versions
XML 1.0 has been defined as W3C Recommendation as of February 1998. The format has been envisioned as lightweight version of SGML specifically for web use and has enjoyed leadership from the side of W3C by Jonathan Bosak and Working Group on XML with representatives of Sun, Microsoft, Netscape, and so forth. XML namespaces appeared as early as in 1999 making it possible to share one document by independent vocabularies without collisions on the side of elements' naming. The same year XSLT 1.0 and XPath 1.0 have appeared defining the concepts of transformations and node selection respectively within publishing and business world.
XML has taken firm position as dominant interchange format by such technologies like RSS feeds,SOAP messages,Atom feeds,XBRL, office document format,Office XML and Android configuration and resources in 2000s'. XML 1.0 had competition from JSON at the beginning of 2010s' but it still remains significant interchange standard in publishing, financial domain, governmental agencies, configuration files,music notation, and standards based interchange. XML 1.0 5th Edition, as well as XML 1.1 2nd edition are W3C standards with wide support for XML 1.0 by most programs.
Related formats
JSON is smaller, is directly compatible with JavaScript objects, but does not have comment, mixed content support, attribute handling, and XML schemas and transformations. YAML is easier on the eyes when you need config files, but harder to parse and has type ambiguity problems while XML is stricter and more fit to use when creating document markup. CSVs work perfectly with flat spreadsheets of data, which can then be opened easily with spreadsheet software and does not represent anything else properly. XHTML and HTML both are markup languages used online, and XML is a metalanguage, meaning XML is a language from which others can be created like XHTML. XSD, DTD, RNG, and SCH check the correctness of XML but do not hold the actual data stored within an XML file. XSL and XSLT convert XML files into other formats like XHTML, normal text, and PDF-preparation markup. DOCX, XLSX, and PPTX are archive files holding multiple XML pieces together and are not single-file Office 2003 .xml documents. MXL means MusicXML compressed and PLIST can mean either of XML and binary.
No comments yet. Be the first to share your experience with this file type.