【问题标题】:Deserialization of xml in iphone sdkiphone sdk中xml的反序列化
【发布时间】:2011-03-21 06:31:09
【问题描述】:

对于 iPhone 应用程序,我从服务器中提取数据作为 xml。我想反序列化 xml 并将数据放入自定义对象中,而无需解析整个 xml

例如:- 如果我的 xml 是这样的

    <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 aboard a stolen Improbability Drive ship commanded by Beeblebrox, ex-president of the Imperial Galactic Government and full-time thief.
        </description>
    </book>

我创建了一个对象“作者”,我想以 Author.Book、Author.Book.Description 的身份访问数据。 有没有人这样做过? 提前致谢

【问题讨论】:

    标签: iphone xml ios4 xml-parsing xml-deserialization


    【解决方案1】:

    虽然 libxml2 包含在 SDK 中,但使用起来非常笨拙,而且可能不直观。我强烈推荐 ElementParser 库来帮助解决问题:它允许使用 CSS 样式的选择器从 XML 中提取数据。请参阅链接页面上的示例,了解您可以执行的操作。

    【讨论】:

      猜你喜欢
      • 2010-11-25
      • 1970-01-01
      • 2012-03-04
      • 2011-03-03
      相关资源
      最近更新 更多