How to create XML String in iPhone to use in web-service requests? - iphone

I want to create XML string to be sent to server through web-service. How do I do it natively in iPhone? Or do I have to use any third party library?
I was not able to download GDATA for iPhone. Any else available? Or any other way to do it?
Please help,
Thanks in advance.

You can create XML file with StringWithFormat method or Some of XML parser allow write XML as well. Please refer link of Parser for writing XML
http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project

You can use JSON parser also....
You may want to refer to SBJSON Framework which is frequently used for objective-C, I have used this framework in may of my iOS Apps.
You may get a reference about it from these links:
https://github.com/stig/json-framework
http://stig.github.com/json-framework/
Example Code: Also here is an example on, How to parse JSON with SBJSON Parser:
How to parse JSON into Objective C - SBJSON
http://jasarien.com/?p=428

Related

XML generation from data in core data iphone

I am going to make an application and in that I want to store user's input in XML file and then parse it to another user,So I am confuse How can I do it, and which XML method should I use? NSXML parser,libxml,touchXML or KissXML?
I think this link will help you to choose best type of xml parser.
How To Choose The Best XML Parser for Your iPhone Project
Thank You

how to create XML Doc in ios

in my current project i need to create one xml file and send it to server.
i searched many sites a got information about some API like
NSXML (now its deprecated)
http://onlinefreecomputertutorials.blogspot.in/2011/07/how-to-read-and-write-xml-documents.html
GDATAXML (now its deprecated)
http://www.raywenderlich.com/725/how-to-read-and-write-xml-documents-with-gdataxml
please if is there any API i can use to create xml or you have any idea just share with me or any link for tutorial to create xml in objective c.
thanks for any help.
Use TCMXMLWriter. It's a small XML library with a very nice syntax.

parsing xml to json in iphone

Am writing one small application to parse from XML to JSON object for iphone. can anyone tell me the availability of open source library present to do the parsing usnig objective-c.
There are plenty of open source solutions in objective-c to deal with JSON :
JSONKit : https://github.com/johnezang/JSONKit
SBJson (aka json-framework) : https://github.com/stig/json-framework
YAJL Framework : https://github.com/gabriel/yajl-objc
To deal with xml, you can use the default NSXMLParser class or some other solutions like some code I've posted here (DOM parser) :
NSXMLParser retrieving wrong data from XML tags
You can also check this page which will give you a good overview of available solutions for XML parsing (and an explaination of differences between SAX and DOM parsers) : http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project
Well there is a json parser available for objective c on github. Its very simple to use. You may have to write some additional code to provide input to the parser.
I use NSPropertyListSerialization from Apple to turn a Plist XML into a dictionary. Then we just need to find something to go from dictionary to JSON.
The json-framework looks like a nice JSON generator.

i want to learn Xml parsing in objective C for iphone

what are the basic things shall i read to understand how parsing xml in Objective-C works
HI,
These links may help for you,
IPhone XML Parsing
XML parsing
go through these tutorials
http://www.w3schools.com/xml/default.asp
This tutorial for Internet data transferring and receiving
http://www.json.org/
and NSXMLParser class reference
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html
Hope this helps
Xml Parsing

How parse html string in iphone

i m using php file for using data in my application,
in this file i post data on the server and if i get the data from the server
then it is in html formate.
so problem is that i have a string with html tags how i use data in that string.
how i extract data from html string.
Use NSXMLParser class. it works for HTML too. There are three useful delegate methods.
If your HTML out put is some simple data - may be you can write some simple NSString parser your self like 'markhunte' mentioned, if you have large complex data in HTML then you have to go for some open source parsers.
Cocoa does not provide HTML parser, Forum discussion claims in some case XML parser itself work for you, but I never go it working for my data.
In my case I had very simple TAG which I had handled using my own parser using NSString.
I have used the code from --> Flatten-html-content-ie-strip-tags-cocoaobjective-c.
There are also examples of its use on SO.
Just use NSScanner, it is great for searching in between tags that are permanent. If you post some page code I help you set up the scanner.