Your comments

Thanks for the example file. The encoding routine didn't properly handle the standalone attribute that follows the encoding attribute in the XML header. 

This bug will be fixed in the next update.
Hello,

if you have a website open in Safari, you can replace the "http://" part with "textastic://" and hit return. This will download the website in Textastic.

This is documented in more detail at the bottom of this page: http://www.textasticapp.com/v4/manual/x-callback-u...
Hi,

the default encoding is only used when creating new files. Opening existing files detects the encoding as described above.

Can you please send me the XML file to support@textasticapp.com so I can try it here?
Hello,

this is how the encoding is detected:

Textastic first tries to detect the file encoding by reading the "com.apple.TextEncoding" extended attribute from the file system. This attribute is set by some apps like TextEdit (and Textastic).

If there is no extended attribute, it tries to read the Byte Order Mark (BOM).

If there is no BOM, it tries to detect the text encoding from the actual file data: To detect encodings of HTML or XML files, it first tries to find "charset=" or "encoding=" strings in the file and uses the encoding specified there. Does your XML file contain "charset=" or "encoding=" strings?

If none of the above worked, UTF-8 is tried.

If UTF-8 does not work, it tries some other encodings like ISO-Latin-1.
Try to select "XML" as the syntax definition in the status bar.

If you want better syntax highlighting, you can add custom syntax definitions to Textastic by using TextMate bundles. See
http://www.textasticapp.com/mac/manual/lessons/How...

A quick search for "kml tmbundle" in Google brought up this TextMate bundle which should work:

I'm just wondering: where is this necessary?
I wouldn't do it automatically, since for example Markdown uses two trailing space characters in a line to signal that the user wants to have a line break (<br>) after this line.

I think it would also be necessary to have an option to show space characters (and other invisibles) similar to how tab characters can already be shown.