Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Firstly, I opened TextEdit. Went to Format Menu & I set option -> Make Plain Text, I entered following Data, Which is to be required in my Application.

<?xml version="1.0" encoding="ISO-8859-1"><tips><Prop_Tips><Tip_ID><![CDATA[1]]></Tip_ID><Category_ID>1</Category_ID><Tip_Title>Play Your Shot</Tip_Title><Tip_Thumb></Tip_Thumb><Tip_image></Tip_image><Tip_Description>Every golfer likes to hit the ball long, high and straight, but experience tells you that you can expect a certain pattern to your shots.</Tip_Description><Category_Name>Course Management/Strategy</Category_Name></Prop_Tips><Prop_Tips><Tip_ID><![CDATA[2]]></Tip_ID><Category_ID>1</Category_ID><Tip_Title>Shots Curve From Sidehill Lies</Tip_Title><Tip_Thumb></Tip_Thumb><Tip_image></Tip_image><Tip_Description>Sidehill fairway lies will cause the ball to curve, slice right or hook left. Here's a tip to help make better contact.</Tip_Description><Category_Name>Course Management/Strategy</Category_Name></Prop_Tips></tips>

After saving this file as UTF-8, Whenever I tried to read my XML file through XMLParser, I am getting following data from file

{\fonttbl\f0\fmodern\fcharset0 Courier-Bold;}

\f0\b\fs24 \cf0 \CocoaLigature0 <?xml version="1.0" encoding="ISO-8859-1"?>\
    <tips><Prop_Tips><Tip_ID><![CDATA[1]]></Tip_ID><Tip_Title>Play Your Shot</Tip_Title><Tip_Description>Every golfer likes to hit the ball long, high and straight, but experience tells you that you can expect a certain pattern to your shots.</Tip_Description></Prop_Tips><Prop_Tips><Tip_ID><![CDATA[2]]></Tip_ID><Tip_Title>Shots Curve From Sidehill Lies</Tip_Title><Tip_Description>Sidehill fairway lies will cause the ball to curve, slice right or hook left. Here's a tip to help make better contact.</Tip_Description></Prop_Tips><Prop_Tips><Tip_ID><![CDATA[3]]></Tip_ID><Tip_Title>Don't Ground The Driver</Tip_Title><Tip_Description>Keep the clubhead just off the ground to get your swing off to a consistently smooth start.</Tip_Description></Prop_Tips><Prop_Tips><Tip_ID><![CDATA[4]]></Tip_ID><Tip_Title>Tilt Your Tee</Tip_Title><Tip_Description>Here's a tip to "max out" into-the-wind drives.</Tip_Description></Prop_Tips></tips>}

Which indicates that, file isn't stored in proper format.

I want to simply save an XML file using TextEdit in Mac OS X.

share|improve this question
up vote 2 down vote accepted

If you are a commmandline type person, you can always use vi.

share|improve this answer
Nope ! I got the solution . Use xCode. – Sagar R. Kothari Aug 24 '09 at 22:48
You have Xcode at your disposal and you didn't think to use it? Granted, it's even more overkill than emacs for plain-text editing, but it gets the job done. – las3rjock Aug 24 '09 at 22:59
While I wouldn't want to gainsay someone else rep, why would you accept an answer that you did not use as the solution? – EBGreen Aug 24 '09 at 23:22
No Sir actually Firstly I implemented the vi editor solution. Then I came to know the easy way about x code plist file. I had completely forgot it. This is so i asked question – Sagar R. Kothari Aug 24 '09 at 23:29

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.



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

share|improve this answer
It sounds like he did (or tried to do) this. – las3rjock Aug 24 '09 at 22:49
yes, las3rjock is right. I tried this & even if i was failure. Look at my Solution. I got the idea. – Sagar R. Kothari Aug 24 '09 at 22:50
P.S. @jtbandes I would give you another +1 if I could for mentioning TextMate. It's probably the most used application on my Mac, since I use it for editing everything. – las3rjock Aug 24 '09 at 22:58
@las3rjock: I only use Xcode for Cocoa stuff, but TextMate for everything else. I love it for web development. – jtbandes Aug 24 '09 at 22:59

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.

share|improve this answer
Actually I don't have any permission to download any extra software & install them. Is there any inbuilt editor available like text editor? – Sagar R. Kothari Aug 24 '09 at 22:42
You could open up a Terminal window; start a command-line editor like pico, emacs, or vi; and type or paste in the contents of your plain-text file. – las3rjock Aug 24 '09 at 22:46

Open XCode.

Go to File Menu

->Select New File.

->Go to Other Option

->select Property list

->Give file name with xml extension.

-> enter your xml data & save.

share|improve this answer
Xcode works, but you should have no problem with TextEdit. You can enter the "xml" extension and it works fine. – jtbandes Aug 24 '09 at 22:57

You must log in to answer this question.

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