For an iPhone app i am pulling data from server as xml.I want to deserialize the xml and get the data into a custom object without parsing through the whole xml
eg:- if my xml is like
<book title="The Hitchhiker's Guide to the Galaxy" price="15.49">
<description>
Join Douglas Adams's hapless hero Arthur Dent as he travels the galaxy with his intrepid pal Ford Prefect, getting into horrible messes and generally wreaking hilarious havoc.
</description>
</book>
<book title="The Restaurant at the End of the Universe " price="14.36">
<description>
Arthur and Ford, having survived the destruction of Earth by surreptitiously hitching a ride on a Vogon constructor ship, have been kicked off that ship by its commander. Now they find themselves aboar开发者_如何学Cd a stolen Improbability Drive ship commanded by Beeblebrox, ex-president of the Imperial Galactic Government and full-time thief.
</description>
</book>
and i create an object "Author" i want to access the data as Author.Book, Author.Book.Description. Has anyone done this before? Thanks in advance
While libxml2 is included in the SDK, it's pretty clunky to use and can be non-intuitive. I strongly recommend the ElementParser library to help things along: it allows using CSS-style selectors to extract data from your XML. See the examples on the linked page for an sample of what you can do.
精彩评论