我将如何解析这个 iPhone 表的 .xml
我正在为一个应用程序创建一个目录,我需要解析我想要在 UITableView 中显示的每个项目的名称、电子邮件、电话号码和办公室。我有一堂课,但我从来没有真正处理过简单的 txt 文件的解析问题。
我需要将 URL 加载到 xml 文件,该文件底部包含以下类型的数据。它没有 xml 标签,但它保存为 .xml
我已经阅读了 NSXMLParsers,但我不确定这是否是执行此操作的正确方法,或者是否有更简单的方法。
下面是 .xml 文件的一部分示例,这只是数百行的一部分,这些行以相同的方式组织,按部门、部门,然后是人员。
感谢您的帮助!
http://cs.millersville.edu/科学与数学学院Dr.FirstH.LastRoddy Science [电子邮件受保护] ScienceMrs.First.LastRoddy 科学 [电子邮件受保护] ScienceDr.FirstH.LastRoddy 科学 [电子邮件受保护] ScienceDr .FirstH.LastRoddy 科学 [电子邮件受保护] ScienceMs.FirstA.GilbertLast Science < a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5516303b213027133c2726217b1934262115383c3939302726233c3939307b3031206d62647867676461163a38 2520213027">[电子邮件受保护] ScienceDr.FirstH.LastRoddy 科学 [电子邮件受保护]
I am making a directory for an app and I need to parse the the names, e-mail, phone #, and office for each item that I want to display in a UITableView. I have a class made but I have never really dealt with pasring anything past simple txt files.
I need to load a URL to a xml file, which consists of the following type of data at the bottom. It does not have xml tags, but it is saved as a .xml
I have read up on the NSXMLParsers, but I wasn't sure if that would be the correct way to do this or if there was an easier way.
Example of part of the .xml file below, this is just part of a few hundred lines that are organized in the same manner, by division, department, then person.
Thanks for any help!
http://cs.millersville.edu/School of Science and MathematicsDr.FirstH.LastRoddy Science [email protected] ScienceMrs.First.LastRoddy Science [email protected] ScienceDr.FirstH.LastRoddy Science [email protected] ScienceDr.FirstH.LastRoddy Science [email protected] ScienceMs.FirstA.GilbertLast Science [email protected] ScienceDr.FirstH.LastRoddy Science [email protected]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法对此文件使用 xml 解析器。
相反,您可以尝试使用 NSScanner 解析文本文件。这里列出了一些教程:
There's no way you can use a xml parser for this file.
Instead you may try to use NSScanner to parse the text file. A couple of tutorials are listed here:
如果没有 xml 标签,您的文件就和纯文本文件一样好......
由换行符分隔的行......
每行包含由点 (.) 或类似内容分隔的数据。找出模式并像解析文本文件一样解析它......
without the xml tags, your file is as good as a plain text file...
rows separated by new line character....
and each line contains data separated by a dot (.) or something like that. figure out the pattern and parse it like you would parse a text file...