11

How can one open an XML file, for example with LibreOffice? If I try, all I see is the text format of XML, with tags and so on.

3
  • 1
    Hi do you wish to edit the file or just view it? You can use gedit help.ubuntu.com/community/gedit ubuntu's build in text editor.
    – gman
    Feb 25, 2014 at 12:07
  • XML files are text files, so any text editor can open it. But if you want to perform XML validation on it, then you need some XML editor that will also load the XSD file related to the XML and perform the validation (check that you enter the correct tag with the correct value type).
    – Benoit
    Mar 14, 2014 at 14:42
  • 2
    And what exactly were you expecting? It's an XML file!
    – terdon
    Mar 15, 2014 at 21:08

6 Answers 6

15

If the file is an XML table, you can open it in LibreOffice Calc through the Data > XML Source menu1. Inside it, you just need to open the XML file, point to the table you're importing on the left column and specify a destination in your sheet in the right text field. Example:

enter image description here

This feature is documented in the Help for LibreOffice Calc and at https://wiki.documentfoundation.org/Development/Calc/XMLSource .

1 Since this is an experimental feature (at least in V 6.1.3.2), it may be unreliable and the menu entry will be greyed out unless experimental features are enabled with ToolsOptionsLibreOfficeAdvancedEnable experimental features.

7
  • What is an "xml table"? How do I find out if my file is one or has one? When I open a file like that, I see nothing in the "Map to document" window, though I see "<s:Table> lines in it. It comes from SOE Software's Clarity Election Night Reporting tool, e.g. the detail.xls file zipped inside results.enr.clarityelections.com/CO/63746/183083/reports/…
    – nealmcb
    Nov 12, 2016 at 15:13
  • Cool, this works in LibreOffice Calc 5.1 with sitemap.xml from a sitemap generator service. I can choose which column to be shown in the sheet. Thanks Waldir. May 3, 2018 at 8:28
  • Quite, what is an XML table? Is it a collection of repeated nodes all of which have the same set of attributes in a two- or three-level structure? Is it converted to a table with each row corresponding to one of the first-level nodes?
    – PJTraill
    Mar 30, 2019 at 22:05
  • When I try this (in LibreOffice Calc 6.1.3.2 on Open Suse Leap), XML source is greyed out in the Data menu – do I have to do something else first?
    – PJTraill
    Mar 30, 2019 at 22:07
  • Some documentation at wiki.documentfoundation.org/Development/Calc/XMLSource , as referenced in the Help (but it says nothing about ungreying the menu entry).
    – PJTraill
    Mar 30, 2019 at 22:14
3

You can also use basex from the software center.

sudo apt-get install basex

BaseX is a very fast and light-weight, yet powerful XML database and XPath/XQuery processor, including support for the latest W3C Full Text and Update Recommendations. It supports large XML instances and offers a highly interactive front-end (basexgui).

I don't have it installed but it has really high ratings from the software center.

1
  • Practical and ugly ;)
    – A.B.
    Apr 28, 2015 at 14:58
0

The default Gedit text editor is capable of opening the file - I also suggest you try Bluefish, which can do XML as well HTML and other languages. It also does auto-completion, and highlighting.

Here are examples of the above editors based on this:

Bluefish screenshot

enter image description here N.B. With Gedit, you have to add some of the above by changing a few settings and activating a few plugins.

0

In case you don't succeed with LibreOffice, try using SoftMaker FreeOffice. This free office suite has much better import and export filters that let you run Microsoft Office formats faithfully. The whole office suite is feature-packed, but needs only 58MB. It's well coded, very fast and reliable. Here's the link where to get it:

www.freeoffice.com

1
  • Kingsoft Office is also worth a try: wpscommunity.org
    – s3lph
    Mar 14, 2014 at 15:52
0

You may find XMLStarlet useful, if you are familiar with XPATH concepts (or prepared to learn them).

This is a command-line tool which can select data from an XML file on the basis of the types of elements and the values of their attributes or those of related elements. I am not sure if it is easy to generate a CSV file or other suitable for loading into LibreOffice (if that is your aim), or whether you would need to transform it a little first. (I shall try to remember to update this if I find out more.)

The examples given in the Wikipedia article (link above) show the command as xml (e.g. xml sel for a selection), but in my case (OpenSuse Leap) it is xmlstarlet, which is also the package to install; I do not know what the situation is for Ubuntu.

0

XML Copy Editor (xmlcopyeditor) is a fast, free, validating XML editor. It features DTD/XML Schema/RELAX NG validation, XSLT, XPath, pretty-printing, syntax highlighting, folding, tag completion/locking, and a spelling/style check. XML Copy Editor can be installed from the default Ubuntu repositories.

XML Copy Editor debugger (xmlcopyeditor-dbg) is an optional add-on for XML Copy Editor that can also be installed from the default Ubuntu repositories.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .