【发布时间】:2015-08-12 10:28:36
【问题描述】:
我有一个要解析的 xml,我成功地做到了,但我对这个 xml 的结构有疑问。
<BIBLEBOOK bnumber="1" bname="Genesis" bsname="Gen">
<CHAPTER cnumber="1">
<VERS vnumber="1">At the first God made the heaven and the earth.</VERS>
<VERS vnumber="2">And the earth was waste and without form; and it was dark on the face of the deep: and the Spirit of God was moving on the face of the waters.</VERS>
如何获取 bname 的值?
这就是我解析 xml 的方式:
NSString *xmlString = [[NSBundle mainBundle] pathForResource:@"basic_english" ofType:@"xml"];
NSData *xmlData = [NSData dataWithContentsOfFile:xmlString];
NSString* dataStr = [[NSString alloc] initWithData:xmlData encoding:NSUTF8StringEncoding];
NSDictionary *xmlDoc = [NSDictionary dictionaryWithXMLString:dataStr];
【问题讨论】:
标签: ios objective-c xml-parsing