Example of ASIHTTPRequest with TouchXML - iphone

I am currently using NSXMLParser mathods to parse my data something like this :
But I found some good option as TouchXML .
I googled for some good example or tutorial
But I can't understand the XPathquery format and the parsing loops as done in this example
or this question
I just want to know how to parse a simple xml document like this :
<ElementsArray>
<ElementObject>
<element1></element1>
<element2></element1>
<ElementObject>
.
.
.
<ElementArray>
so can anyone give me example code or a link will also be useful.

The coolest part of using TouchXML is that you can use the Apple documentation for NSXML and simply replace the NS with C. So an NSXMLDocument is a CXMLDocument and an NSXMLNode is a CXMLNode, and so on. Just look at the Tree-Based XML Programming Guide from Apple for sample code and you should get a pretty good idea of how to use TouchXML with your XML documents. The section Querying an XML Document should give you what you need to use XPath effectively.

Related

write to JSON Beginner

I need to find a good tutorial that would guide me to write to a JSON file. and also to read from a JSON file and populate core-data with it.
I have googled for days, and couldn't find a good tutorial. Can someone give me a sample code or point me to a good tutorial. I am new to objective-c
to introduce the structure of JSON, http://json.org/
and if you scroll down, you will find links to several open-source (which you can use as examples) projects which implement JSON serializing and deserializing. basically, there, you will find much more code examples in their projects than anyone here can ever really post as a response to your question.

How to use NSXMLParser?

I have some XML which I need parsed in my Objective-C code. The XML is fairly simple. I have already searched Stackoverflow as well as Google but I did not find what I am looking for. Examples if how to use NSXMLParser would be useful, and if anyone has any suggestions on how to do this another way please let me know.
Did you look at the Apple sample applications? From the NSXMLParser class reference, I found no fewer than five sample projects that did parsing.
GKTank
KMLViewer
LazyTableImages
SeismicXML (probably your best bet, and most directly related)
XMLPerformance
I recommend going through this tutorial by Ray Wenderlich:
http://www.raywenderlich.com/725/how-to-read-and-write-xml-documents-with-gdataxml
It uses GDataXML, which from my experience is a light-weight easy to use XML parser. It goes through all the basic steps to read and write to an XML document in a specific directory, including making or ammending to the file if it doesnt exist or exists respectively.

how to parse using xml parser in iphone?

Am able to parse
< name>Walmart< /name>
using xml parser
but how to parse
*< s:image link="http://i.walmartimages.com/i/p/00/02/72/42/77/0002724277837_500X500.jpg"/>*
using xml parse in iphone.
Thanks in advance
There are various ways of doing this. My personal favorite is using Xpath via TFHpple. Xpath is clearly documented and easy to understand at W3schools. Sorry, I can't link to it. Spam filter prevents it.
I've used this approach for all sorts of things, and it is also great to note that you can use this library with HTML data as well.
I got the solution......
No need to go to parser libraries...
We can parse such tags using NSXMLParser with the help of attribute concepts....
thanks for you all for helping me....
cheers

NSXMLDocument replacement on iPhone?

I have seen how an NSXMLDocument can parse an html document and provide easy methods for returning parts of the html structure.
Is there a similar method that can be used for the iPhone, as NSXMLDocument is not available?
Have you seen TouchXML?
http://code.google.com/p/touchcode/wiki/TouchXML
You might try this small document class which simply uses NSXMLParser:
https://github.com/nfarina/xmldocument
Also see this blog post:
http://notes.bikemonkey.org/post/47351363/googles-nsxmldocument-replacement-for-iphone
Google has written a replacement for some NSXML stuff for iPhone.

XML with Cocoa Touch

I am a new learner at the area of Objective-C. I would like to retrieve data from XML page on the iPhone. Is it possible? It would be more helpful to me if I get an appropriate suggestion or code.
The SDK comes with the NSXMLParser class. Some people prefer to use the libxml2 library as it can be faster and more memory efficient than NSXMLDocument but you may want to wrap it with an Objective C layer as it is a C API. See this example.
There was a good episode of cocoaFusion: the other day that covered the ins and outs of XML parsing. Head on over to cocoafusion.net and look for Episode 2: An intro to using web APIs and XML.
The show notes section for that episode has some sample code downloads and links to other sites that contain more information (including some of the links mentioned in the other answers here).
Cheers!
A good article that lays out how you can use NSXMLParser to rip through xml.
Parsing XML in Cocoa
There is also some other libraries: TouchXML, KissXML.
Check out the SiesmicXML tute on Apple's iPhone developer site. It uses the XMLParser in a dedicated thread to parse XML in a backgroud process.
JK