【问题标题】:Getting XML values [duplicate]获取 XML 值 [重复]
【发布时间】: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


    【解决方案1】:

    试试这个。希望对你有帮助。

    NSString *bname = [xmlDoc valueForKey:@"_bname"];
    

    【讨论】:

      猜你喜欢
      • 2017-01-02
      • 2023-03-11
      • 2019-12-03
      • 1970-01-01
      • 2013-11-05
      • 2012-08-13
      • 2015-07-09
      • 1970-01-01
      • 2013-08-14
      相关资源
      最近更新 更多