How to Run an XML File on Linux

Files that end in the .xml file extension are plain text files containing XML code. Rather than "execute" them like you would a program or script, you'd simply open it in one of two ways—in a text editor or a web browser. You can also convert the file to a different format using a converter like xmlto.

Using a Text Editor

Press Control+Alt+T.

This opens a terminal window.

Navigate to the directory containing your XML file.

You’ll use the cd command to do this. For example, cd /usr/local/files takes you to a directory called /usr/local/files.

Type vim filename.xml.

Replace filename.xml with the name of the XML file you want to view. This opens the file for viewing and editing in VIM.

Using a Web Browser

Navigate to the .xml file you want to view.

If you’re using Gnome, you can open GNOME Files and double-click the folder where the file is stored. If you’re using KDE, the built-in file manager is Dolphin.

Right-click the file and select Open With Other Application.

A list of applications will appear.

Select your web browser.

Firefox comes preinstalled on many Linux flavors, but you can use any modern web browser—they should all display XML files. This will automatically display the contents of the file.

Converting to Another Format

Press Control+Alt+T.

This opens a terminal window.

Update the repository.

To make sure you’re downloading the latest version of xmlto, the tool yo’ull be using to convert the XML file to plain text, run the command sudo apt update.

Install the xml2 package.

To install xmlto, run the command sudo apt install xmlto.

Navigate to the directory containing your XML file.

You’ll use the cd command to do this. For example, cd /usr/local/files takes you to a directory called /usr/local/files.

Run the command to convert the file to another format.

The command you’ll use depends on the type of file you want to create:

  • xmlto pdf myfile.xml converts to a PDF.
  • To convert to another file type, replace pdf with the desired file type, such as: html, htmlhelp (HTML help file), javahelp (Java help file), dvi (text DVI file), man (Unix manual pages), txt (plain text), ps (postscript), xhtml, fo (XSL-FO formatting objects).

Leave a Comment