私のアプリでは、xmlファイルから値を取得してラベルに出力する必要があるTBXMLパーサーを使用しています...これはサーバー内の私のxmlファイルです
<gold>
<price>
<title>22 K Gold</title>
</price>
<price>
<title>24 K Gold</title>
</price>
</gold>
私のViewcontroller.hは次のようになります
#import <UIKit/UIKit.h>
#import "TBXML.h"
@interface ViewController : UIViewController{
IBOutlet UILabel *lab;
TBXML *tbxml;
}
@end
私のViewcontrooler.mは次のようになります
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSData *xmlData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:@"http://www.abcde.com/sample.xml"]];
tbxml = [[TBXML alloc]initWithXMLData:xmlData];
TBXMLElement * root = tbxml.rootXMLElement;
if (root)
{
TBXMLElement * elem_PLANT = [TBXML childElementNamed:@"price" parentElement:root];
while (elem_PLANT !=nil)
{
TBXMLElement * elem_BOTANICAL = [TBXML childElementNamed:@"title" parentElement:elem_PLANT];
NSString *botanicalName = [TBXML textForElement:elem_BOTANICAL];
lab.text=[NSString stringWithFormat:@"re %@", botanicalName];
elem_PLANT = [TBXML nextSiblingNamed:@"price" searchFromElement:elem_PLANT];
elem_BOTANICAL = [TBXML childElementNamed:@"title" parentElement:elem_PLANT];
botanicalName = [TBXML textForElement:elem_BOTANICAL];
lab1.text=[NSString stringWithFormat:@"re %@", botanicalName];
}
}
}
BAD_ACCESSスレッドを取得しています。何かが足りませんか...ヘルプpls...