can't open KML files created w/ Apple TextEdit

384 views
Skip to first unread message

j

unread,
Jun 28, 2007, 6:24:58 PM6/28/07
to KML Developer Support - Getting Started
I cannot open KML files created with the TextEdit software that comes
standard on Apple MacBook. I have copied and pasted the KML samples
from Google:
http://code.google.com/apis/kml/documentation/kml_tut.html
I have also tried retyping these same samples manually into TextEdit.
In each case, when I attempt to open the file with GE, it recognizes
it as a KML file. However, when it opens the file, I get the
following error:
Open of file xyz failed: Parse error at line 1, column 0: not well-
formed (invalid token).
Why there would be an error at the very first character, I can't say.
I have not found any similar errors described elsewhere in the forum.
I must be making a very simple mistake. Suggestions?
Thanks,
Joe

ManoM

unread,
Jun 29, 2007, 12:08:39 PM6/29/07
to KML Developer Support - Getting Started
Hi Joe,

Sometimes this happens if you put a space or anything in front of the
XML declaration at the front of the file, this line:

<?xml version="1.0" encoding="UTF-8"?>

If that's not the problem, can you post copies of the KML that you
created in the Files section of this group? Don't just copy and paste
it here, we need to see the actual files. Maybe we can debug them.

ManoM

j

unread,
Jun 29, 2007, 4:04:09 PM6/29/07
to KML Developer Support - Getting Started
That's what I was afraid of, so I tried to retype the first line, and
when that didn't work, I tried retyping the entire KML file from
scratch. I have posted a file called "test" in the Files section as
you requested.

Thanks for the help,
Joe

ManoM

unread,
Jun 29, 2007, 4:28:29 PM6/29/07
to KML Developer Support - Getting Started
Hi Joe,

I've replicated the problem, and I see why it's happening, but I don't
know why TextEdit is doing it. When I open your file in a text editor,
I get:

{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420
{\fonttbl\f0\fswiss\fcharset77 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard
\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql
\qnatural\pardirnatural

\f0\fs24 \cf0 <?xml version="1.0" encoding="UTF-8"?>\
<kml xmlns="http://earth.google.com/kml/2.1">\
<Document>\
<Placemark>\
<name>CDATA example</name>\
<description>\
<![CDATA[\
<h1>CDATA Tags are useful!</h1>\
<p><font color="red">Text is <i>more readable</i> and \
<b>easier to write</b> when you can avoid using entity \
references.</font></p>\
]]>\
</description>\
<Point>\
<coordinates>102.595626,14.996729</coordinates>\
</Point>\
</Placemark>\
</Document>\
</kml>}

The first 7 lines and the {} are what are causing your problem. Are
you saving as a text file?

ManoM

j

unread,
Jun 29, 2007, 4:31:18 PM6/29/07
to KML Developer Support - Getting Started
Yes, I am saving as rich text file because TextEdit for Mac doesn't
not provide for saving as a .txt file. I will have to download a
simple text editor. Do you recommend one?

Thanks,
Joe

ManoM

unread,
Jun 29, 2007, 4:50:18 PM6/29/07
to KML Developer Support - Getting Started
Ah, that's the issue.

Well, there's always JEdit, which the Earth Outreach folks have a
great tutorial on:

http://earth.google.com/outreach/tutorial_jedit.html

That shows how to use JEdit to validate your KML file. JEdit requires
Java. Other people really like Emacs and vi, which I'm sure are
available for the Mac.

ManoM

ManoM

unread,
Jun 29, 2007, 5:28:39 PM6/29/07
to KML Developer Support - Getting Started
The Mac user sitting next to me just told me that vi comes with the
Mac.

ManoM

Philippe

unread,
Aug 2, 2007, 7:37:23 AM8/2/07
to KML Developer Support - Getting Started
On Jun 29, 10:31 pm, j wrote:
> Yes, I am saving as rich text file because TextEdit for Mac doesn't
> not provide for saving as a .txt file. I will have to download a
> simple text editor. Do you recommend one?

I recommend using TextEdit for Mac. It *does* provide editing plain
text-files. Menu > Format > Make Plain Text

Jonathan van Tuijl

unread,
Aug 2, 2007, 10:19:48 AM8/2/07
to KML Developer Support - Getting Started

You can set the default in the prefs, if you don't generally use it to
create rich text files.

TextWrangler <http://www.barebones.com/products/textwrangler/> is a
good free plain text editor for Macs. It beats the heck out of
TextEdit, and unlike vi or emacs it won't scare newbies away before
they even get to open the program.

Jonathan

Reply all
Reply to author
Forward
0 new messages