我正在开发一个调用API的项目,它返回一个Xml数据,在我的代码类里面有解析数据并将其提取到UI上显示(这里使用了NSXMLParser)。我附加了屏幕截图xml响应和为解压缩数据而编写的代码部分(解析代码我不在这里粘贴)
提取代码:
else if ([adType isEqualToString:@"textAd"])
{
NSString *html = [xml.documentRoot getNamedChild:@"htmlString"].text;
CGSize bannerSize;
if(adspaceHeight > 0 && adspaceWidth > 0)
{
bannerSize = CGSizeMake(adspaceWidth, adspaceHeight);
}
else if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
{
bannerSize = CGSizeMake(728, 90);
}
else
{
bannerSize = CGSizeMake(320, 50);
}
UIWebView *webView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, bannerSize.width, bannerSize.height)];
//load HTML string later (to avoid calling impression pixels when using custom events)
if(!headers) { //means that it's an interstitial ad
_htmlString = [NSString stringWithFormat: @"<style>*
{ -webkit-tap-highlight-color: rgba(0,0,0,0);} body {height:100%%; width:100%%;
}
img {max-width:100%%;
max-height:100%%; width:auto; height:auto; position: absolute; margin: auto; top: 0; left: 0; right: 0; bottom: 0;}
</style>
%@",html];
} else {
_htmlString = html;
}
if([skipOverlay isEqualToString:@"1"]) {
wasUserAction = NO;
webView.delegate = (id)self;
webView.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
[webView addGestureRecognizer:tap];
tap.delegate = self;
} else {
webView.delegate = nil;
webView.userInteractionEnabled = NO;
// add overlay later, only if no custom event is shown
}
webView.backgroundColor = [UIColor clearColor];
webView.opaque = NO;
webView.scrollView.scrollsToTop = false;
self.bannerView = webView;
}
现在对我来说,我想为另一个xml结构修改相同的代码...... 我正在粘贴我必须处理的响应的屏幕截图。请帮助我检索每个节点内的数据。(特别是“ads”标签内有两个链接。如何单独检索它们)。