今天先来说一下GDataXMLNode--xml解析吧(DOM方式解析XML文件),当然还有其他的解析方式,这个还是以后再更新
1.环境的配置

导入libxml2.tdb。对于Xcode7.0及以上版本,库的后缀名都改成为tdb。Xcode7.0以下的,库的后缀名仍然是dylib。所以这里看你的Xcode版本。

找到“Header Search Paths”项,并添加“/usr/include/libxml2”到列表中。

这时,如果直接编译的话,会报”ARC forbids explicit message send of 'autorelease",原因是因为GDataXML并没有采用ARC,所以需要把GDataXML的ARC去掉。解决方法:
在Build Phases选项,找到Compile Sources,选中GDataXMLNode.m,加入-fno-objc-arc编译选项。

最后的话,编译就可以通过啦


这是两种不同的写法 ,当然解析都是一样的 参考http://blog.csdn.net/lu1300274/article/details/7377323
附上自己写的 2和3层的xml 解析《这里使用的话改变 EasyTong Table 这里的 根节点 和 子节点 就好了 ,这里的解析出来 我转成了字典格式 。字典用的方便嘛》
2层xml 解析

3层xml 解析


最后在附上一种错误:
Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
Google后查证,iOS9引入了新特性App Transport Security (ATS)。详情:App Transport Security (ATS)
新特性要求App内访问的网络必须使用HTTPS协议。
但是现在公司的项目使用的是HTTP协议,使用私有加密方式保证数据安全。现在也不能马上改成HTTPS协议传输。
最终找到以下解决办法:
在Info.plist中添加NSAppTransportSecurity类型Dictionary。
在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES
网友评论