我尝试在我的应用程序中使用RaptureXML,因为我知道它很容易实现解析。我试图解析远程XML文件并从中获取图像并将其视为UIImageView。当我试图调用我的远程XML文件时,我收到了一个警告和两个错误,如下所示,
我使用的ViewController如下所示,
- (void)viewDidLoad
{
[super viewDidLoad];
RXMLElement *rootXML = [RXMLElement elementFromURL:[NSURL URLWithString:@"http://myxml.com/Sample.xml"]];
RXMLElement *rxmlProducts = [rootXML child:@"Products"];
NSArray *myarray = [rxmlPlayers children:@"Main"];
UIImage *currentImage = [myarray objectAtIndex:0];
customimage.image = currentImage;
}
My Remote XML文件如下所示,
<Products>
<Main id="1">
<name>Main</name>
<mainimage id="1">http://myimage.com/images/first.png</mainimage>
<mainimage id="2">http://myimage.com/images/second.png</mainimage>
</Main>
<Category id="1">
<name>category1</name>
<categoryimage id="2">http://myimage.com/images/img1.png</categoryimage>
</Category>
<Category id="2">
<name>category2</name>
<categoryimage id="2">http://myimage.com/images/img2.png</categoryimage>
<subcategoryimage id="1">http://myimage.com/images/img5.png</subcategoryimage>
<subcategoryimage id="2">http://myimage.com/images/img4.png</subcategoryimage>
</Category>
</Products>
任何人都可以告诉我如何解决此错误以及如何使用RaptureXML.解析上述远程XML文件
答案 0 :(得分:2)
最后,我按照RaptureXML GitHub的建议通过以下方式解决了ARC错误的问题。
对于ARC问题
由于这是链接器错误
RXMLElement.m
是否在该列表中,如果未在列表中添加该文件。现在ARC错误将由链接器解决。对于'elementFromURL:'已弃用问题
答案 1 :(得分:0)
好的有两个问题:
1)RaptureXML的作者已使用以下注释弃用此commit中的elementFromURL
方法:
建议您自己处理网络操作 让RaptureXML处理XML
2)看起来你没有使用一个(静态?)库,它已经被编译为支持iPhone模拟器(架构i386)。为了解决这个问题,你需要自己重新编译,包括支持或者找到一个已经有这种支持的在线人员。