0

I'm using NSXMLParser to parse a local XML file on my iPad. Now I want to modify the file. I want to put some lines at the almost end of it.

This is what my file looks like:

<dict>
    <element att1="atribute" att2="atribute" att3="atribute" att4="atribute" />
    <element att1="atribute" att2="atribute" att3="atribute" att4="atribute" />
    <element att1="atribute" att2="atribute" att3="atribute" att4="atribute" />
    <element att1="atribute" att2="atribute" att3="atribute" att4="atribute" />
</dict>

How could I solve this? I tried to load a dictionary or array "with contents of file..." but it always returned (null) in the log.

Any ideas?

Julian F. Weinert
  • 7,474
  • 7
  • 59
  • 107
  • What is your exact code for loading the file? – Dan F May 22 '12 at 16:52
  • The XML file is pulled form an API into the documents directory of the app: `NSData *data = [[NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://.../get.php"] encoding:NSUTF8StringEncoding error:nil] dataUsingEncoding:NSUTF8StringEncoding]; [data writeToFile:xmlPath atomically:YES];` I'm now creating a new entry and passing it back to the API. Now I want to add the entry to the local file too so that I don't have to download entire file again (it's very large). – Julian F. Weinert May 22 '12 at 17:58
  • And where along here is the error happening? – Dan F May 22 '12 at 21:17
  • There is no error... I'm searching for a solution how I can do this! – Julian F. Weinert May 25 '12 at 14:40

1 Answers1

1

Use GDataXML to add data to XML file. You can find a tutorial for writing to xml Here

Boeckm
  • 3,264
  • 4
  • 36
  • 41
Shan
  • 131
  • 7