How to Read Parse XML in Objective C? - objective-c

What framework I should use to grab XML from a http and parse that?

Start here:
http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html
You can use the initWithContentsOfURL initializer to actually load the document from the HTTP source.

Try touchXML:
TouchXML is a lightweight replacement
for Cocoa's NSXML* cluster of classes.
It is based on the commonly available
Open Source libxml2 library.
Here is a nice tutorial.
Source has moved a bit, can be found here

Related

Web scraping in Objective C

is there any Objective C library for parsing HTML, like python's BeautifulSoup? Thanks
From Apple's part there is NSXMLDocument and NSXMLParser, which support tidied HTML input. (Tree-Based XML Programming Guide)
On iOS (4.3) there's currently no NSXMLDocument available, so you'd have to use either NSXMLParser or libxml2.2.
Some more informations on potential problems with parsing malformed HTML:
What's the best approach for parsing XML/'screen scraping' in iOS? UIWebview or NSXMLParser?
The most reliable solution is to use an off-screen WebView, load the HTML source into it and then access its DOM tree.
The best way I have found is NSXMLParser + libtidy. However, there are many third party libraries are available now which makes parsing easier. (last answer was written in 2011).
Google's Gumbo HTML5 parser is pretty good. It's written in pure C99 and you can use it with Objective C (use a wrapper like this one).
If you want pure Objective C libraries then Ono or hpple are good. HTMLReader is also a good alternative.
If Swift is your thing, you could use NDHpple which is a swift wrapper based on hpple. Or You could use Swift-HTML-Parser. (Bonus: Alamofire is as good as Python Requests and is a joy to use)

iPhone app server communication XML or JSON?

Which method is easier and more efficient? XML or Json
Where can I find a tutorial and code samples for each?
I recently learned how to use JSON on the iPhone and it was very easy.
Here's a framework:
http://code.google.com/p/json-framework/
General JSON info can be found here:
http://www.json.org/

How do you read/write/update m4u and mp3 file meta data using cocoa/objective c?

Are there some particular library files available on OS/X that are relevant, I am just not sure where to start.
You'd probably want to use the QuickTime for that. There is some sample code that does this. However, it's not the nicest way to access metadata. The newer QTKit Framework somehow still requires you to fall back to the C-based APIs. There is another example from Apple embedding meta data writing into a Objective-C method. This might be the best starting point for you.

Extract Objective-C class information from library at runtime

I was wondering if there were a way to extract information from an objective-c app, static or dynamic library and/or framework?
Information such as an array of class names without instantiating or running the target.
I've checked google and the apple developer documentation and haven't found anything.
Frank
F-script appears to be able to do what you want, but I'm no expert. Check out www.fscript.org.
If you want to extract classes from an application/dynamic library, there is a handy tool called ClassDump.
It can even generate the header files in order to get an overview of the classes, protocols, etc.
If you want to do it at runtime, then take a look at the source code to learn how to load and parse the different mach-o segments.
This is an excellent starting point for reverse-engineering Cocoa apps:
http://culater.net/wiki/moin.cgi/CocoaReverseEngineering
It mentions F-Script, class-dump, and a few others.

Parsing and Writing XML in MAC 10.3.9 Cocoa?

What is the Best way i can do Parsing or Writing into XML using cocoa for mac10.3.9.?
Im mentioning the version of OS specifically because, i read in the documentation like, Mac 10.3.9 sdk does not support NSXML class.?
I Found an OpenSource libaray (libxml), is it the only library i can use????
Please give me some suggestion regarding the above....
Kindly reply Soon...
Thank you
Pradeep.
According to my copy of the documentation, the NSXMLParser class is available on Mac OS X 10.3 and later.
If for some reason you cannot use that, you can also use the Core Foundation XML Parser functions (search for CFXMLParser). This is a C-based API also developed by Apple. It will be deprecated in future versions of Mac OS X (after Snow Leopard), but since you're working on 10.3 that won't be a concern for you.
Many who cannot use those two also use libxml. Objective-C is able to use any C-based libraries with no penalty. I'm fairly certain Mac OS X ships with a copy of libxml you can link to (no need to download, build, or ship the library yourself; though if you want to, you certainly can).
What's best is going to depend on what features you need. Namespaces, for example, aren't fully supported by NSXMLParser in 10.3, but they are supported in 10.4.
Thanks for the replies....
I used libxml for xml parsing, it was working fine.
But still it has some problems like, even if the xml file is half consistent(i mean if the xml is corrupt, it loads the xml file).
libxml with xpath made things quite easy for xml parsing.