0

OK, I managed to read from an XML file using NSXMLParser, but now I don't know how to write to an XML file. I have an XML file, say:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<user id="abcd" password="pass1"/>
<user id="efg" password="pass2"/>
</root>

Now when a new user enters details, I want to store them in a new tag. Lets say like, the id is "hhhh" and password is "pass3".

I want to add a new tag with attributes as such:

<user id="hhhh" password="pass3"/>

to the XML file.

How should I do this? Please explain in an elaborate way. I am a newbie here. Any links to tutorials or examples will be much helpful.

Thanks.

1
  • i want to know how you solved this Commented Oct 11, 2011 at 3:40

3 Answers 3

2

Check out the Tree-Based XML Programming Guide. You might use NSXMLDocument and friends. You could also search the web for open-source alternatives (there are plenty that parse and a few that write). A quick Google search for "using NSXMLDocument" yields several third-party tutorials.

It's better that you read the documentation yourself first and ask more specific questions. Help us help you. :-)

Sign up to request clarification or add additional context in comments.

Comments

0

There's a number of really good third party XML parsers you can take a look at that will probably make it easier on you.

Here's a good post I found talking about them. http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project

1 Comment

Ray also has a post showing how to specifically use Google's GDataXML library. raywenderlich.com/725/…
0

Try using kissxml.

The goal is to create an NSXML style API that can used in environments without NSXML (e.g. iPhone).

KissXML was inspired by the TouchXML project, but was created to add full support for generating XML as well as supporting the entire NSXML API.

Please support this free and open source project

address

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.