编辑代码

#import <Foundation/Foundation.h>
#import "XMLReader.h"
int main(int argc, char* argv[]) {
    NSString * str=@"<msg>"
    "<appmsg sdkver="0">"
    "<title><![CDATA[马斯克脑机接口下一步:让大猩猩用脑电波玩视频游戏,今年人体试验!]]></title>"
    "<des><![CDATA[马斯克:5年登火星,1个月地火往返]]></des>"
    "<action></action>"
    "<type>5</type>"
    "<showtype>1</showtype>"
    "<content><![CDATA[]]></content>"
    "<contentattr>1</contentattr>"
    "<url><![CDATA[http://mp.weixin.qq.com/s?__biz=MzI3MTA0MTk1MA==&mid=2652097355&idx=1&sn=2edb141cd9b1c50325e829a650d5bc64&chksm=f120bfbac65736ac645fe182104b1ebf0964f12d963775f14db34c18300500146548e80da179&scene=0&xtrack=1#rd]]></url>"
    "<lowurl><![CDATA[]]></lowurl>"
    "<appattach>"
    "<totallen>0</totallen>"
    "<attachid></attachid>"
    "<fileext></fileext>"
    "</appattach>"
    "<extinfo></extinfo>"
    "<mmreader>"
    "<category type="20" count="5">"
    "<name><![CDATA[新智元]]></name>"
    "<topnew>"
    "<cover><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV88H1SXoCZibaKTN9mrFCtysuYhr3V4obHjib7sWc3baWOVo0PwbeoOPRw/640?wxtype=jpeg&wxfrom=0]]></cover>"
    "<width>0</width>"
    "<height>0</height>"
    "<digest><![CDATA[马斯克:5年登火星,1个月地火往返]]></digest>"
    "</topnew>"
    "<item>"
    "<itemshowtype>0</itemshowtype>"
    "<title><![CDATA[马斯克脑机接口下一步:让大猩猩用脑电波玩视频游戏,今年人体试验!]]></title>"
    "<url><![CDATA[http://mp.weixin.qq.com/s?__biz=MzI3MTA0MTk1MA==&mid=2652097355&idx=1&sn=2edb141cd9b1c50325e829a650d5bc64&chksm=f120bfbac65736ac645fe182104b1ebf0964f12d963775f14db34c18300500146548e80da179&scene=0&xtrack=1#rd]]></url>"
    "<shorturl><![CDATA[]]></shorturl>"
    "<longurl><![CDATA[]]></longurl>"
    "<pub_time>1612239821</pub_time>"
    "<cover><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV88H1SXoCZibaKTN9mrFCtysuYhr3V4obHjib7sWc3baWOVo0PwbeoOPRw/640?wxtype=jpeg&wxfrom=0]]></cover>"
    "<tweetid></tweetid>"
    "<digest><![CDATA[马斯克:5年登火星,1个月地火往返]]></digest>"
    "<fileid>0</fileid>"
    "<sources>"
    "<source>"
    "    <name><![CDATA[新智元]]></name>"
    "</source>"
    "</sources>"
    "<styles></styles>"
    "<native_url></native_url>"
    "<del_flag>0</del_flag>"
    "<contentattr>1</contentattr>"
    "<play_length>0</play_length>"
    "<play_url><![CDATA[]]></play_url>"
    "<player><![CDATA[]]></player>"
    "<music_source>0</music_source>"
    "<pic_num>0</pic_num>"
    "<vid></vid>"
    "<author><![CDATA[]]></author>"
    "<recommendation><![CDATA[]]></recommendation>"
    "<pic_urls></pic_urls>"
    "<comment_topic_id>1722140088509202432</comment_topic_id>"
    "<cover_235_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV88H1SXoCZibaKTN9mrFCtysuYhr3V4obHjib7sWc3baWOVo0PwbeoOPRw/640?wxtype=jpeg&wxfrom=0]]></cover_235_1>"
    "<cover_1_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8BrXgmNXQkncuG5XFnich9YdXJCmtHLGibj0mzqbRMFJwovDG3NXjJGTw/300?wxtype=jpeg&wxfrom=0]]></cover_1_1>"
    "<cover_16_9><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV88H1SXoCZibaKTN9mrFCtysuYhr3V4obHjib7sWc3baWOVo0PwbeoOPRw/640?wxtype=jpeg&wxfrom=0]]></cover_16_9>"
    "<appmsg_like_type>2</appmsg_like_type>"
    "<video_width>0</video_width>"
    "<video_height>0</video_height>"
    "<is_pay_subscribe>0</is_pay_subscribe>"
    "</item>"
    "<item>"
    "<itemshowtype>0</itemshowtype>"
    "<title><![CDATA[波士顿动力又出新视频!Spot 机器狗这次竟学会了跳绳...]]></title>"
    "<url><![CDATA[http://mp.weixin.qq.com/s?__biz=MzI3MTA0MTk1MA==&mid=2652097355&idx=2&sn=4de6a0ebfb12fd081c589f8766d4018a&chksm=f120bfbac65736acd6c2c879878aa1bc06544b4269a2ab24bfb456432e5a1bd35ef688cf06b2&scene=0&xtrack=1#rd]]></url>"
    "<shorturl><![CDATA[]]></shorturl>"
    "<longurl><![CDATA[]]></longurl>"
    "<pub_time>1612239821</pub_time>"
    "<cover><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8mZZmpfvumGmZt7BtXO1ScF0dza1ya8QH76vuIBZIibSzD4DicYmcdQEg/300?wxtype=jpeg&wxfrom=0]]></cover>"
    "<tweetid></tweetid>"
    "<digest><![CDATA[看波士顿动力的机器狗Spot跳绳!]]></digest>"
    "<fileid>0</fileid>"
    "<sources>"
    "<source>"
    "    <name><![CDATA[新智元]]></name>"
    "</source>"
    "</sources>"
    "<styles></styles>"
    "<native_url></native_url>"
    "<del_flag>0</del_flag>"
    "<contentattr>0</contentattr>"
    "<play_length>0</play_length>"
    "<play_url><![CDATA[]]></play_url>"
    "<player><![CDATA[]]></player>"
    "<music_source>0</music_source>"
    "<pic_num>0</pic_num>"
    "<vid></vid>"
    "<author><![CDATA[]]></author>"
    "<recommendation><![CDATA[]]></recommendation>"
    "<pic_urls></pic_urls>"
    "<comment_topic_id>1722140089515835402</comment_topic_id>"
    "<cover_235_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8mZZmpfvumGmZt7BtXO1ScF0dza1ya8QH76vuIBZIibSzD4DicYmcdQEg/300?wxtype=jpeg&wxfrom=0]]></cover_235_1>"
    "<cover_1_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8mZZmpfvumGmZt7BtXO1ScF0dza1ya8QH76vuIBZIibSzD4DicYmcdQEg/300?wxtype=jpeg&wxfrom=0]]></cover_1_1>"
    "<cover_16_9><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8mZZmpfvumGmZt7BtXO1ScF0dza1ya8QH76vuIBZIibSzD4DicYmcdQEg/300?wxtype=jpeg&wxfrom=0]]></cover_16_9>"
    "<appmsg_like_type>2</appmsg_like_type>"
    "<video_width>0</video_width>"
    "<video_height>0</video_height>"
    "<is_pay_subscribe>0</is_pay_subscribe>"
    "</item>"
    "<item>"
    "<itemshowtype>0</itemshowtype>"
    "<title><![CDATA[特斯拉「甩锅」国家电网遭打脸!官微发文致歉]]></title>"
    "<url><![CDATA[http://mp.weixin.qq.com/s?__biz=MzI3MTA0MTk1MA==&mid=2652097355&idx=3&sn=3392a42bf6027133064eb189483427f0&chksm=f120bfbac65736ac67692cfcddf86025bbdc8fa0d0214a1998ba3c82ad411e89cc5f7808c44a&scene=0&xtrack=1#rd]]></url>"
    "<shorturl><![CDATA[]]></shorturl>"
    "<longurl><![CDATA[]]></longurl>"
    "<pub_time>1612239821</pub_time>"
    "<cover><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8Jq4DyOrfj5FZeLE0mumU9bynhp6vslFaZeFiaWqJWzF1rvasyLafIIw/300?wxtype=jpeg&wxfrom=0]]></cover>"
    "<tweetid></tweetid>"
    "<digest><![CDATA[甩锅王?]]></digest>"
    "<fileid>0</fileid>"
    "<sources>"
    "<source>"
    "    <name><![CDATA[新智元]]></name>"
    "</source>"
    "</sources>"
    "<styles></styles>"
    "<native_url></native_url>"
    "<del_flag>0</del_flag>"
    "<contentattr>0</contentattr>"
    "<play_length>0</play_length>"
    "<play_url><![CDATA[]]></play_url>"
    "<player><![CDATA[]]></player>"
    "<music_source>0</music_source>"
    "<pic_num>0</pic_num>"
    "<vid></vid>"
    "<author><![CDATA[]]></author>"
    "<recommendation><![CDATA[]]></recommendation>"
    "<pic_urls></pic_urls>"
    "<comment_topic_id>1722140090119815178</comment_topic_id>"
    "<cover_235_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8Jq4DyOrfj5FZeLE0mumU9bynhp6vslFaZeFiaWqJWzF1rvasyLafIIw/300?wxtype=jpeg&wxfrom=0]]></cover_235_1>"
    "<cover_1_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8ayklMwnMzf9qqEVtxA1ZWeTG6GCk1fWibVTrMzdlIP92Smicib2Bm9AcQ/300?wxtype=jpeg&wxfrom=0]]></cover_1_1>"
    "<cover_16_9><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8Jq4DyOrfj5FZeLE0mumU9bynhp6vslFaZeFiaWqJWzF1rvasyLafIIw/300?wxtype=jpeg&wxfrom=0]]></cover_16_9>"
    "<appmsg_like_type>2</appmsg_like_type>"
    "<video_width>0</video_width>"
    "<video_height>0</video_height>"
    "<is_pay_subscribe>0</is_pay_subscribe>"
    "</item>"
    "<item>"
    "<itemshowtype>0</itemshowtype>"
    "<title><![CDATA[受显微镜下线虫启发, MIT人工智能实验室推出「液态」神经网络]]></title>"
    "<url><![CDATA[http://mp.weixin.qq.com/s?__biz=MzI3MTA0MTk1MA==&mid=2652097355&idx=4&sn=801b8b3936752abd920427e03330223d&chksm=f120bfbac65736ac386a4e7ce55b98a5e603fce37b3fb338a8559a77876cdb616cb4bc5f057e&scene=0&xtrack=1#rd]]></url>"
    "<shorturl><![CDATA[]]></shorturl>"
    "<longurl><![CDATA[]]></longurl>"
    "<pub_time>1612239821</pub_time>"
    "<cover><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8JFyJD6iaBXVl5sZ2xnIHjMIpObfBXwO8icEWlgobGeYeNxIIjtqZU2pQ/300?wxtype=jpeg&wxfrom=0]]></cover>"
    "<tweetid></tweetid>"
    "<digest><![CDATA[这是何方神圣?]]></digest>"
    "<fileid>0</fileid>"
    "<sources>"
    "<source>"
    "    <name><![CDATA[新智元]]></name>"
    "</source>"
    "</sources>"
    "<styles></styles>"
    "<native_url></native_url>"
    "<del_flag>0</del_flag>"
    "<contentattr>0</contentattr>"
    "<play_length>0</play_length>"
    "<play_url><![CDATA[]]></play_url>"
    "<player><![CDATA[]]></player>"
    "<music_source>0</music_source>"
    "<pic_num>0</pic_num>"
    "<vid></vid>"
    "<author><![CDATA[]]></author>"
    "<recommendation><![CDATA[]]></recommendation>"
    "<pic_urls></pic_urls>"
    "<comment_topic_id>1722140090639908869</comment_topic_id>"
    "<cover_235_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8JFyJD6iaBXVl5sZ2xnIHjMIpObfBXwO8icEWlgobGeYeNxIIjtqZU2pQ/300?wxtype=jpeg&wxfrom=0]]></cover_235_1>"
    "<cover_1_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8pAMBibibsTSsrSjSSKgn4k7XuZoHOXoE7sLJAeLPXUo318aAzUyR1cmg/300?wxtype=jpeg&wxfrom=0]]></cover_1_1>"
    "<cover_16_9><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8JFyJD6iaBXVl5sZ2xnIHjMIpObfBXwO8icEWlgobGeYeNxIIjtqZU2pQ/300?wxtype=jpeg&wxfrom=0]]></cover_16_9>"
    "<appmsg_like_type>2</appmsg_like_type>"
    "<video_width>0</video_width>"
    "<video_height>0</video_height>"
    "<is_pay_subscribe>0</is_pay_subscribe>"
    "</item>"
    "<item>"
    "<itemshowtype>0</itemshowtype>"
    "<title><![CDATA[中国学者研发新型电子纹身,实现8倍延展,用于医疗、VR和可穿戴机器人等领域]]></title>"
    "<url><![CDATA[http://mp.weixin.qq.com/s?__biz=MzI3MTA0MTk1MA==&mid=2652097355&idx=5&sn=b87091f87d937b9fc394dd52ab095636&chksm=f120bfbac65736ac18792b1cf942e4b7ccdd0ca983b2df3c8e049d8a73d80c73a3ea2c915eec&scene=0&xtrack=1#rd]]></url>"
    "<shorturl><![CDATA[]]></shorturl>"
    "<longurl><![CDATA[]]></longurl>"
    "<pub_time>1612239821</pub_time>"
    "<cover><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8ibwucqu4BDdIZeDMiaVBX0eTydf56pqqYRVJFEQOUVHu56BZzqv343mQ/300?wxtype=jpeg&wxfrom=0]]></cover>"
    "<tweetid></tweetid>"
    "<digest><![CDATA[集成多层电路]]></digest>"
    "<fileid>0</fileid>"
    "<sources>"
    "<source>"
    "    <name><![CDATA[新智元]]></name>"
    "</source>"
    "</sources>"
    "<styles></styles>"
    "<native_url></native_url>"
    "<del_flag>0</del_flag>"
    "<contentattr>0</contentattr>"
    "<play_length>0</play_length>"
    "<play_url><![CDATA[]]></play_url>"
    "<player><![CDATA[]]></player>"
    "<music_source>0</music_source>"
    "<pic_num>0</pic_num>"
    "<vid></vid>"
    "<author><![CDATA[]]></author>"
    "<recommendation><![CDATA[]]></recommendation>"
    "<pic_urls></pic_urls>"
    "<comment_topic_id>1722140091176779779</comment_topic_id>"
    "<cover_235_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8ibwucqu4BDdIZeDMiaVBX0eTydf56pqqYRVJFEQOUVHu56BZzqv343mQ/300?wxtype=jpeg&wxfrom=0]]></cover_235_1>"
    "<cover_1_1><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8HOPcGAWl0aCm3RIqYiaf22u90MicrRqjtniblOxDWdS10VQ52D3whCmrA/300?wxtype=jpeg&wxfrom=0]]></cover_1_1>"
    "<cover_16_9><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV8ibwucqu4BDdIZeDMiaVBX0eTydf56pqqYRVJFEQOUVHu56BZzqv343mQ/300?wxtype=jpeg&wxfrom=0]]></cover_16_9>"
    "<appmsg_like_type>2</appmsg_like_type>"
    "<video_width>0</video_width>"
    "<video_height>0</video_height>"
    "<is_pay_subscribe>0</is_pay_subscribe>"
    "</item>"
    "</category>"
    "<publisher>"
    "<username><![CDATA[gh_108f2a2a27f4]]></username>"
    "<nickname><![CDATA[新智元]]></nickname>"
    "</publisher>"
    "<template_header></template_header>"
    "<template_detail></template_detail>"
    "<forbid_forward>0</forbid_forward>"
    "</mmreader>"
    "<thumburl><![CDATA[https://mmbiz.qpic.cn/mmbiz_jpg/UicQ7HgWiaUb2IcpY7kd8P5f0XVQtRbBV88H1SXoCZibaKTN9mrFCtysuYhr3V4obHjib7sWc3baWOVo0PwbeoOPRw/640?wxtype=jpeg&wxfrom=0]]></thumburl>"
    "</appmsg>"
    "<fromusername><![CDATA[gh_108f2a2a27f4]]></fromusername>"
    "<appinfo>"
    "<version></version>"
    "<appname><![CDATA[新智元]]></appname>"
    "<isforceupdate>1</isforceupdate>"
    "</appinfo>"
    "</msg>";
    NSError *error;
    NSMutableDictionary *xmlDict = [XMLReader dictionaryForXMLString:str error:&error];
    NSMutableDictionary *msgDict = [xmlDict valueForKey:@"msg"];
    NSMutableDictionary *appMsgDict = [msgDict valueForKey:@"appmsg"];
    NSMutableDictionary *mmreaderDict = [appMsgDict valueForKey:@"mmreader"];
    NSMutableDictionary *categoryDict = [mmreaderDict valueForKey:@"category"];
    NSArray *items = [categoryDict valueForKey:@"item"];
    NSLog(@"消息内容:%@", items);
    return 0;
}