Is there any XML binding framework for Objective-C?
I've tried a few searches on google and didn't find anything yet.
I'm looking for something that r开发者_如何学Ceads from a XSD/DTD/XML and generate:
- the Model classes to store values
- the actual parser that reads from the XML and populate the model classes
Here is a vast and simple tutorial that helps to read as well as create xml documents using GDataXMLParser http://www.raywenderlich.com/725/how-to-read-and-write-xml-documents-with-gdataxml
There seems to be a bit of confusion about SAXy. It is not another DOM library like NSXMLDocument or KissXML.
SAXy targets a different problem space, that of binding XML directly to domain objects using the lighter-weight event driven model. It's more akin to JAXB or Castor in the Java world.
It's closest relative in the Objective-C realm is the modeling code in RestKit. Although, RestKit advertises XML support, it's largely been dropped from the current version. SAXy was written to fill the void.
You may want to look at NSXMLDocument
. Apple XML Programming Guide: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/NSXML_Concepts/NSXML.html
I haven't found any external framework for XML-Binding, still I think you should check the Apple provided solution.
For parsing XML I preffer libxml2, here is a simple tutorial of how to embed this powerful parser in your project.
Hope I helped you.
LibXML is the best solution for this requirement. It can load your DTD and parse the XML. You can also use XPath to map Model with the data inside XML structure
I dont know whether it works for you or not but GData objective c library from Google can solve your purpose . You can serach for GDataXML objective C on google. you will get the link to code.google.com . You can check out if they support this thing. GData is really a vast library , so may be it can solve the things for you .
There is now a full-featured XML Marshalling framework for Objective-C on github:
https://github.com/reaster/saxy
It has a clean API, automatically maps classes to elements, is highly configurable using the blocks and works on iOS with no third-party dependencies.
If the format is not important for you, you can use plist format ! This is a XML with DTD some different !
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
However you can read directly this plist with NSDictionary (read NSDictionary documentation). It's so powerful and quick! No additional framework.
精彩评论