How to store an XML document in Mac OS X?

Solution 1:

It looks like your file was saved as RTF, containing all that extra data you saw.

To switch TextEdit over to Plain Text Mode, press ⇧⌘T (Shift-Command-T), or select "Make Plain Text" from the Format menu.

before

after

If you're doing a lot of code editing, I also recommend getting TextMate, a proper code editor with XML support:

enter image description here

Solution 2:

Looking at the file formats in the "File->Save As..." dialog box in TextEdit, it seems that plain text is not among them. The default is Rich Text Format (hence the \rtf command codes in your file), and the other formats (in broad categories) are HTML, OpenDocument, and Word. You should probably use a plain-text format text editor such as TextWrangler to create and edit files like this.

EDIT: Plain-text formats do appear after you select "Format->Make Plain Text", but that still doesn't explain how sagar ended up with RTF when he tried to save in UTF-8 format.