【问题标题】:Best way in objective-c to turn XML like structure to dictionary在objective-c中将类似XML的结构转换为字典的最佳方法
【发布时间】:2015-05-03 04:06:19
【问题描述】:

我的查询输出如下所示:

<ticker-entry gamecode=\"2015050110\" gametype=\"Playoffs\"><visiting-team display_name=\"Tampa Bay\" alias=\"TB\" nickname=\"Lightning\" id=\"20\" division=\"ECA\" conference=\"EC\" score=\"2\"><score heading=\"1\" value=\"0\"></score><score heading=\"2\" value=\"0\"></score><score heading=\"3\" value=\"1\"></score><score heading=\"OT\" value=\"0\"></score><score heading=\"OT2\" value=\"1\"></score><score heading=\"T\" value=\"2\"></score></visiting-team><home-team display_name=\"Montreal\" alias=\"Mon\" nickname=\"Canadiens\" id=\"10\" division=\"ECA\" conference=\"EC\" score=\"1\"><score heading=\"1\" value=\"0\"></score><score heading=\"2\" value=\"0\"></score><score heading=\"3\" value=\"1\"></score><score heading=\"OT\" value=\"0\"></score><score heading=\"OT2\" value=\"0\"></score><score heading=\"T\" value=\"1\"></score></home-team><gamestate status=\"Final\" display_status1=\"Final\" display_status2=\"2OT\" href=\"http://scores.nbcsports.msnbc.com/nhl/recap.asp?g=2015050110\" tv=\"NBCS/CBC\" gametime=\"7:00 PM\" gamedate=\"5/1\" is-dst=\"1\" is-world-dst=\"1\"></gamestate></ticker-entry>

它看起来像 XML,但我编写的 XML 解析器对此无能为力,因为括号不仅具有像 normale xml 中那样的单个单词的属性

<foo>
  <bar>Value</bar>
</foo>

那么在objective-c中,将这个字符串拆分成逻辑结构的好方法是什么?

感谢您的帮助!

【问题讨论】:

    标签: ios objective-c xml parsing


    【解决方案1】:

    如果将\" 标记替换为",它将被解析为完全有效的XML。我认为这是你唯一的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-28
      • 2010-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-10
      相关资源
      最近更新 更多