我正在尝试解析这个 XML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0">
<channel>
<title><![CDATA[App Reviews for Free - Reviews]]></title>
<link><![CDATA[http://appreviewsforfree.weebly.com/reviews.html]]></link>
<description><![CDATA[Reviews]]></description>
<pubDate>Fri, 18 Oct 2013 15:06:45 -0600</pubDate>
<generator>Weebly</generator>
<item>
<title><![CDATA[Asphalt 8 Review]]></title>
<link><![CDATA[http://appreviewsforfree.weebly.com/1/post/2013/10/asphalt-8-review.html]]></link>
<comments><![CDATA[http://appreviewsforfree.weebly.com/1/post/2013/10/asphalt-8-review.html#comments]]></comments>
<pubDate>Fri, 18 Oct 2013 21:30:46 GMT</pubDate>
<category><![CDATA[Uncategorized]]></category>
<guid isPermaLink="false">http://appreviewsforfree.weebly.com/1/post/2013/10/asphalt-8-review.html</guid>
<description><![CDATA[I HATE racing games and have really bad experience with them. I was really hesitant to download Asphalt 8 especially because it was paid. However right now it is the most used app on my iPad! Asphalt 8 has graphics so good it really looks like a game from the future. I really recommend it and hope you enjoy it as much as I do.Positives:Graphics are truly beautifulControls are easy to learn [...]]]></description>
<content:encoded><div class="paragraph" style="text-align:left;">I <strong>HATE </strong>racing games and have really bad experience with them. I was really hesitant to download Asphalt 8 especially because it was paid. However right now it is the most used app on my iPad! Asphalt 8 has graphics so good it really looks like a game from the future. I really recommend it and hope you enjoy it as much as I do.<br /><br />Positives:<br /><ul><li>Graphics are truly beautiful<br /></li><li>Controls are easy to learn<br /></li><li>Level Difficulty is just right<br /></li></ul><br /><br />Negatives:<br /><ul><li>Sometimes gets frustrating&nbsp;<br /></li></ul></div> <div class="wsite-youtube" style="margin-bottom:10px;marg<![CDATA[in-top:10px;"><div class="wsite-youtube-wrapper wsite-youtube-size-hd wsite-youtube-align-center"> <div class="wsite-youtube-container"> <iframe src="http://www.youtube.com/embed/eoUEPu68Vww?wmode=opaque" frameborder="0" allowfullscreen></iframe> </div> </div></div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Burt Destruction 2 Review]]></title>
<link><![CDATA[http://appreviewsforfree.weebly.com/1/post/2013/10/burt-destruction-2-review.html]]></link>
<comments><![CDATA[http://appreviewsforfree.weebly.com/1/post/2013/10/burt-destruction-2-review.html#comments]]></comments>
<pubDate>Fri, 18 Oct 2013 14:52:23 GMT</pubDate>
<category><![CDATA[Uncategorized]]></category>
<guid isPermaLink="false">http://appreviewsforfree.weebly.com/1/post/2013/10/burt-destruction-2-review.html</guid>
<description><![CDATA[Always wished there was Mario in the App Store? Introducing the next Mario: Bart Destruction 2! Bart Destruction 2 is an AMAZING game in which you run to the end. The controls are so easy: Just tap to jump and double tap to jump really high. You have to jump on top of enemies to kill them. I really recommend this game to all gamers.Positives:Really easy controls Gr [...]]]></description>
<content:encoded><div class="paragraph" style="text-align:left;">Always wished there was Mario in the App Store? Introducing the next Mario: Bart Destruction 2!&nbsp;&nbsp;Bart Destruction 2 is an <strong>AMAZING </strong>game in which you run to the end. The controls are so easy: Just tap to jump and double tap to jump really high. You have to jump on top of enemies to kill them. I really recommend this game to all gamers.<div><br></div><div>Positives:</div><div><ul><li>Really easy controls&nbsp;<br></li><li>Great Graphics<br></li><li>You can record your game<br></li></ul></div><div><br></div><div>Negatives:</div><div><br></div><div><ul><li>Needs Mini-games<br></li></ul></div><div><br></div></div> <div class="wsite-youtube" style="margin-bottom:10px;margin-top:10px;"><div class="wsite-yo<![CDATA[utube-wrapper wsite-youtube-size-auto wsite-youtube-align-center"> <div class="wsite-youtube-container"> <iframe src="http://www.youtube.com/embed/pQi_-ZBGEWs?wmode=opaque" frameborder="0" allowfullscreen></iframe> </div> </div></div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Movie Clock HD Review]]></title>
<link><![CDATA[http://appreviewsforfree.weebly.com/1/post/2013/10/movie-clock-hd-review.html]]></link>
<comments><![CDATA[http://appreviewsforfree.weebly.com/1/post/2013/10/movie-clock-hd-review.html#comments]]></comments>
<pubDate>Thu, 17 Oct 2013 14:05:09 GMT</pubDate>
<category><![CDATA[Uncategorized]]></category>
<guid isPermaLink="false">http://appreviewsforfree.weebly.com/1/post/2013/10/movie-clock-hd-review.html</guid>
<description><![CDATA[Hate waiting for movies to come out? Want to see what others are saying about a movie? We found a perfect solution! Introducing the number one move app: Movie Clock HD. Movie Clock HD is an app in which you can see when a movie is coming out, see what others are saying about, and follow a specific movie. Positives:Amazing UIEasy to useAccurate N [...]]]></description>
<content:encoded><div class="paragraph" style="text-align:left;">Hate waiting for movies to come out? Want to see what others are saying about a movie? We found a perfect solution! &nbsp;Introducing the number one move app: Movie Clock HD.&nbsp;Movie Clock HD is an app in which you can see when a movie is coming out, see what others are saying about, and follow a specific movie.&nbsp;<br /><br />Positives:<br /><ul><li>Amazing UI<br /></li><li>Easy to use<br /></li><li>Accurate&nbsp;<br /></li></ul><br /><br />Negatives<br /><ul><li>Still can't find one!</li></ul></div> <div class="wsite-youtube" style="margin-bottom:10px;margin-top:10px;"><div class="wsite-youtube-wrapper wsite-youtube-size-auto wsite-youtube-align-center"> <div class="wsite-youtube-container"> <iframe src="http://www.youtube.com/embed/Kc19Q3HNVmc?wmode=opaque" f<![CDATA[rameborder="0" allowfullscreen></iframe> </div> </div></div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Apache 3D Sim Review]]></title>
<link><![CDATA[http://appreviewsforfree.weebly.com/1/post/2013/10/apache-3d-sim-review.html]]></link>
<comments><![CDATA[http://appreviewsforfree.weebly.com/1/post/2013/10/apache-3d-sim-review.html#comments]]></comments>
<pubDate>Thu, 17 Oct 2013 12:15:49 GMT</pubDate>
<category><![CDATA[Uncategorized]]></category>
<guid isPermaLink="false">http://appreviewsforfree.weebly.com/1/post/2013/10/apache-3d-sim-review.html</guid>
<description><![CDATA[Did you always want to fly a helicopter? Did you ever want to go on hard and fun missions? We found the game for you! Apache 3D Sim is a game in which you can fly a helicopter, go on missions, or just fly around for fun.Positives:Easy to controlGreat GraphicsNegatives:Needs more missions [...]]]></description>
<content:encoded><![CDATA[<div class="paragraph" style="text-align:left;">Did you always want to fly a helicopter? Did you ever want to go on hard and fun missions? We found the game for you! Apache 3D Sim is a game in which you can fly a helicopter, go on missions, or just fly around for fun.<br /><br />Positives:<br /><ul><li>Easy to control<br /></li><li>Great Graphics<br /></li></ul><br /><br />Negatives:<br /><ul><li>Needs more missions</li></ul></div> <div class="wsite-youtube" style="margin-bottom:10px;margin-top:10px;"><div class="wsite-youtube-wrapper wsite-youtube-size-auto wsite-youtube-align-center"> <div class="wsite-youtube-container"> <iframe src="http://www.youtube.com/embed/K6zTiBOMkXg?wmode=opaque" frameborder="0" allowfullscreen></iframe> </div> </div></div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Infinity Blade 3 Review]]></title>
<link><![CDATA[http://appreviewsforfree.weebly.com/1/post/2013/10/infinity-blade-3-review.html]]></link>
<comments><![CDATA[http://appreviewsforfree.weebly.com/1/post/2013/10/infinity-blade-3-review.html#comments]]></comments>
<pubDate>Wed, 16 Oct 2013 20:24:07 GMT</pubDate>
<category><![CDATA[Uncategorized]]></category>
<guid isPermaLink="false">http://appreviewsforfree.weebly.com/1/post/2013/10/infinity-blade-3-review.html</guid>
<description><![CDATA[Infinity Blade 3 is a fantastic game with a lot of ups and downs. It is the last game of the Infinity Blade trilogy and is really worth the $7. Some users are complaining about crashes but it never crashed on me. I guess it only crashes on older devices.Positives:Amazing graphicsGreat StoryGet to play 2 charactersStays fun even when you finish the game [...]]]></description>
<content:encoded><![CDATA[<div class="paragraph" style="text-align:left;">Infinity Blade 3 is a <strong>fantastic </strong>game with a lot of ups and downs. It is the last game of the Infinity Blade trilogy and is really worth the $7. Some users are complaining about crashes but it never crashed on me. I guess it only crashes on older devices.<br /><br />Positives:<br /><ul><li>Amazing graphics<br /></li><li>Great Story<br /></li><li>Get to play 2 characters<br /></li><li>Stays fun even when you finish the game<br /></li></ul><br /><br />Negatives:<br /><ul><li>The price<br /></li><li>Game is short and a little easy<br /></li><li>Takes so long loading<br /></li><li>Crashes on older devices<br /></li></ul><br />Short video of Infinity Blade 3 Gameplay:</div> <div class="wsite-youtube" style="margin-bottom:10px;margin-top:10px;"><div class="wsite-youtube-wrapper wsite-youtube-size-auto wsite-youtube-align-center"> <div class="wsite-youtube-container"> <iframe src="http://www.youtube.com/embed/uxDzaFg34ms?wmode=opaque" frameborder="0" allowfullscreen></iframe> </div> </div></div>]]></content:encoded>
</item>
</channel>
</rss>
使用此代码:
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if ([elementName isEqualToString:@"item"]) {
isBlogPost = YES;
}
if ([elementName isEqualToString:@"title"] && isBlogPost == YES) {
NSString *reviewName = [NSString stringWithFormat:@"%@",[attributeDict objectForKey:elementName]];
NSLog(@"%@",reviewName);
}
}
但是 NSLogs 返回 nil。为什么会这样?对不起,如果这是一个愚蠢的问题,但我从未解析过 xml。