8

I am trying to open a relatively large XML file (50mb) but my Mac just won't open it: No errors though, just been waiting for almost 10 minutes but nothing happens.

Tried using TextEditor, Xcode

Any other suggestions?

2
  • 1
    Have you verified that the file isn't corrupt? If you cat the file, can you see the contents? In Terminal, type cat foobar.xml
    – Allan
    Jul 10, 2017 at 21:21
  • yes, the file is not corrupt, I have a bunch of similar XML files, all of the ones that are a small size 1-5mb are opening just fine.
    – inside
    Jul 11, 2017 at 13:29

6 Answers 6

7

Depending on the source of the file, you may wish to investigate its contents in other ways than just opening it (double clicking). For this, you should use the command line.

Some suggested starting points (where "whatever.xml" is the name of the file):

file whatever.xml

This will tell you what type the file is. Not by file extension, but by actual examination of the contents.

head whatever.xml

This will show you the first ten lines of the file. However, be warned: It is possible to have an entire 50 MB XML file consisting of a single line. Press Ctrl-C to stop if it starts spewing garbage. (Yes, Control C, not Command-C.)

To just view the file without even the possibility of editing it:

less whatever.xml

If the file does consist of very long lines, for reading it, you could force periodic line wraps (formatting):

fmt whatever.xml | less

But actually, less will wrap the lines by default unless you tell it not to. For no wrapping of lines (so you can use sideways arrow keys to scroll):

less -S whatever.xml

It is a good probability that one of these commands will disclose a problem with the file.

4

My goto editor for large files is BBEdit. I've opened much larger files (200MB+ log files) without any slowdown. I've even used it to open binary files in order to look for ascii strings. If BBEdit can't open it, nothing can.

2
  • I've used TextWrangler successfully on very large files and it won't choke the way Sublime or others might. Since they are "sunsetting" TextWrangler in favour of BBEdit, I say this is correct. If you have an old copy of TW, that could work too.
    – cleaver
    Jul 11, 2017 at 10:49
  • I had originally written a paragraph about why I was recommending BBEdit over TextWrangler but deleted it because it didn't seem relevant to the question and it was longer than my actual answer.
    – Ɱark Ƭ
    Jul 11, 2017 at 11:44
3

I use Sublime Text 3 to do some of my editing. A very nice and fairly fast programmable (with plugins) editor. I've just tried it on a 50 mb text file and it didn't seem to have a problem. Sublime Text 3 is not free but their free trial period seems to be endless. While I was checking Sublime Text I tried Atom too. Atom was slower at loading but once it got loaded it seemed fine.

1
  • I use Sublime Text 3 for a lot of stuff too. It might be able to handle large text files, but not large XML files. I tried opening a 64 MB XML file in the most recent version now, and it took several minutes to open the file. Dec 4, 2019 at 12:10
1

Try Sublime Text or Atom to open your XML file.

1

If you just want to open it (not edit), try xmllint command in Terminal:

xmllint --format ~/Desktop/file.xml

There's man page for xmllint command line tool: Go here

0

Working with bigger XML files I suggest to give it a try to Oxygen XML Editor or Sublime Text.
While the first is my editor of choice for its versatility it is also quite heavy. If you just have to go for an easy reading or searching & replacing, it can be done in Sublime Text 3. It takes its time but it doesn't crash.
All the others editor I tried were not able to open the file (I am talking about bigger xml files, >200MB), or they took ages. Moreover, both Oxygen and Sublime provide you with the code highlighting option (in case you are dealing with RDF languages for example...).
Hope it helps

You must log in to answer this question.

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