简体   繁体   English

目标C解析XML

[英]Objective C Parsing XML

I have an xml like this... 我有这样的xml ......

    <object>
<list name="subscriptions">
<object>
<string name="id">feed/http://feeds.feedburner.com/computerdefense</string>
<string name="title">.:Computer Defense:.</string>
<list name="categories">
<object>
<string name="id">user/14761688561595773457/label/Hacking</string>
<string name="label">Hacking</string>
</object>
</list>
<string name="sortid">7372F971</string>
<number name="firstitemmsec">1240520939961</number>
<string name="htmlUrl">http://www.computerdefense.org</string>
</object>
<object>
<string name="id">feed/http://www.rawseo.com/news/feed/</string>
<string name="title">A blend of programming and seo</string>
<list name="categories">
<object>
<string name="id">user/14761688561595773457/label/Hacking</string>
<string name="label">Hacking</string>
</object>
</list>
<string name="sortid">D6766911</string>
<number name="firstitemmsec">1258495136927</number>
<string name="htmlUrl">http://www.rawseo.com/news</string>
</object>
<object>
<string name="id">feed/http://it-adsense.blogspot.com/atom.xml</string>
<string name="title">AdSense Blog-Italiano</string>
<list name="categories">
<object>
<string name="id">
user/14761688561595773457/label/Seo e Web Marketing
</string>
<string name="label">Seo e Web Marketing</string>
</object>
</list>
<string name="sortid">9FB570ED</string>
<number name="firstitemmsec">1233684720758</number>
<string name="htmlUrl">http://it-adsense.blogspot.com/</string>
</object>
<object>
<string name="id">feed/http://feeds.feedburner.com/aextnet</string>
<string name="title">AEXT.NET NET MAGAZINE</string>
<list name="categories"/>
<string name="sortid">70800CFE</string>
<number name="firstitemmsec">1277627346000</number>
<string name="htmlUrl">http://aext.net</string>
</object>
<object>
<string name="id">feed/http://feeds.feedburner.com/alessandroscoscia</string>
<string name="title">Alessandro Scoscia</string>
<list name="categories"/>
<string name="sortid">51CB8E6E</string>
<number name="firstitemmsec">1217001547735</number>
<string name="htmlUrl">http://www.alessandroscoscia.it</string>
</object>
<object>

Can someone show how can I parse it? 有人可以展示我该如何解析它? The text that i need to parse is in body variable 我需要解析的文本是在body变量中

NSMutableString *body = [[NSMutableString alloc]initWithData:responseData encoding:NSASCIIStringEncoding];

I need to insert all info in one Array or in a NSDictionary 我需要在一个数组或NSDictionary中插入所有信息

Best to use an objective-c parsing library. 最好使用objective-c解析库。

This article has a good run down of some of the available ones: 这篇文章对一些可用的文章有很好的了解:

http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project

Also, this page has full code samples using one of the libraries: 此外,此页面包含使用其中一个库的完整代码示例:

http://www.raywenderlich.com/725/how-to-read-and-write-xml-documents-with-gdataxml http://www.raywenderlich.com/725/how-to-read-and-write-xml-documents-with-gdataxml

Follow this answer.May this will help you a lot. 请听下这个答案。愿这对你有所帮助。 Use XMLReader to parse xml in ios.This file efficiently will parse xml for you in to a easily manageable NSDictionary. 使用XMLReader解析ios中的xml。这个文件有效地将xml解析为一个易于管理的NSDictionary。

XML Parsing XML解析

i use the TBXML and works perfectly 我使用TBXML并且工作得很好

The only problem are the accented characters, in Brazil we use a lot, now you do not exist for problems with this ... 唯一的问题是重音字符,在巴西我们使用了很多,现在你不存在这个问题......

is permitted by Apple Store submission Apple Store提交允许

[]'s []的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM