views:

950

answers:

2

I am using text-editor to store xml files.

I know how to read xml files in iPhone application. But the problem which do i get is explained below.

When I store xml files through text-editors, it looks perfect.

But when iPhone - xCode debugs, xml file data is shown as below.

What kind of mistake have I Done?


{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf460 {\fonttbl\f0\fmodern\fcharset0 Courier-Bold;} {\colortbl;\red255\green255\blue255;} \margl1440\margr1440\vieww9000\viewh8400\viewkind0 \pard\tx480\tx960\tx1440\tx1920\tx2400\tx2880\tx3360\tx3840\tx4320\tx4800\tx5280\tx5760\tx6240\tx6720\tx7200\tx7680\tx8160\tx8640\tx9120\tx9600\tx10080\tx10560\tx11040\tx11520\tx12000\tx12480\tx12960\tx13440\tx13920\tx14400\tx14880\tx15360\tx15840\tx16320\tx16800\tx17280\tx17760\tx18240\tx18720\tx19200\tx19680\tx20160\tx20640\tx21120\tx21600\tx22080\tx22560\tx23040\tx23520\tx24000\tx24480\tx24960\tx25440\tx25920\tx26400\tx26880\tx27360\tx27840\tx28320\tx28800\tx29280\tx29760\tx30240\tx30720\tx31200\tx31680\tx32160\tx32640\tx33120\tx33600\tx34080\tx34560\tx35040\tx35520\tx36000\tx36480\tx36960\tx37440\tx37920\tx38400\tx38880\tx39360\tx39840\tx40320\tx40800\tx41280\tx41760\tx42240\tx42720\tx43200\tx43680\tx44160\tx44640\tx45120\tx45600\tx46080\tx46560\tx47040\tx47520\tx48000\ql\qnatural\pardirnatural

\f0\b\fs24 \cf0 \CocoaLigature0 \ Play Your ShotEvery golfer likes to hit the ball long, high and straight, but experience tells you that you can expect a certain pattern to your shots.Shots Curve From Sidehill LiesSidehill fairway lies will cause the ball to curve, slice right or hook left. Here's a tip to help make better contact.Don't Ground The DriverKeep the clubhead just off the ground to get your swing off to a consistently smooth start.Tilt Your TeeHere's a tip to "max out" into-the-wind drives.}


Above given data isn't my xml file.

I tried to save my xml file through textEditor.

But it prefix something before my xml data.

What should be done by me to avoid this problem?

my actual xml data is following.

<?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>
+2  A: 

Are you editing your XML file with TextEdit or something? You've got a whole bunch of RTF data in there, which would seem to imply that you're overwriting your XML data with RTF'd XML. Try using a text editor like Property List Editor or TextWrangler instead.

Dave DeLong
sugar
No, Even Xcode plist file is also creating some kind of problems. Finally I tried vi editor. It worked.
sugar
+4  A: 

Seems like you have written your XML file in a Rich Text Editor. It is saving the file in .rtf format, instead of raw text/xml. Maybe the editor you are using has the option to save as raw txt. That should solve it.

You could also create the file using XCode. It will surely use raw txt.

Jongsma
Yes, No need to install any thing extra. The Best solution is XCode.
sugar
No, Even Xcode plist file is also creating some kind of problems.Finally I tried vi editor. It worked.
sugar
You shouldn't use PLists.In XCode, when creating a new file, go to the bottom of the sidebar where it says 'Other'. Then choose the empty file format. Name it to whatever you like (golftips.xml) and save it. This will create a raw text file.
Jongsma