用于 XML 解析的 Objective-C 库
我想了解 Objective-C 中用于 xml 解析的一些库。我认为这是一个非常常见的需求,但我发现处理此任务的资源有限:
在 Objective-C 语言中使用 XML 的最佳解决方案是什么?请指教。
您的产品使用的解决方案是什么?
I would like to know some libraries in objective-C for xml parsing. I think it is a very common need, but I found limited resources for handling this task:
What is your best solution to work with XML in objective-C language? Please advice.
What is the solution that you have used for your product?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NSXMLParser是一个面向流的类;您对其进行设置并在检测到某些内容时获取委托回调。通常这不是您想要做的,但可以更快且占用更少的内存。
TouchXML 将使用 libxml 解析 XML 本身,并为整个 XML 结构创建一个对象树。这使您可以使用手动遍历方法或基本 XPath(计划提供更复杂的 XPath 支持)轻松访问 XML 树的内容。
NSXMLParser is a stream-oriented class; you set it up and get delegate callbacks when it detects something. Usually this is not what you want to do, but can be much faster and lower memory.
TouchXML will parse the XML itself using libxml, and create an object tree for the entire XML structure. This allows you to easily access the contents of the XML tree, using manual traversal methods or basic XPaths (more sophisticated XPath support is planned).
它的用途很窄,但如果您的目标是解析不整洁的 HTML,您可能想尝试一个我开始称为 标签抓取器。它不能正确处理许多/大多数 XML/HTML 实体,但可以很容易地对其进行修补。 URL:http://github.com/searls/TagScraper
它的价值在于它提供了一个简单的XPath为您隐藏整理/查询/组装的机制,然后它提供解析的元素和信息。
Tag.h
节点的树状数据结构中的属性。It serves a narrow purpose, but if your goal is to parse untidy HTML, you might want to try a static library I started called TagScraper. It doesn't handle many/most XML/HTML entities correctly, but it could be pretty easily patched to. URL: http://github.com/searls/TagScraper
Its value is that it provides a simple XPath mechanism that hides the tidying/querying/assembling for you, and then it provides the parsed elements & attributes in a tree-like data structure of
Tag.h
nodes.