views:

118

answers:

2

Hi,

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.

+5  A: 

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.

benzado
Note that, as of Snow Leopard, “CFXMLParser will be officially deprecated in a future release of Mac OS X” (source: CFXMLParser.h). This isn't a problem for the questioner yet, since he's supporting such an old version of Mac OS X, but the rest of us should prefer and move to alternatives.
Peter Hosey
Good point! I updated my answer just in case somebody reads it years from now and doesn't look at the comments. :-)
benzado
A: 

Hi....every one... 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.

Pradeep Kumar