objective-c的最佳方式是将XML结构转换为字典

时间:2022-09-02 10:46:17

I have a query output which looks like this:

我有一个查询输出,如下所示:

<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>

It looks like XML but the XML parser I wrote can't do anything with this since the brackets have attributs not only a single word like in normale xml

它看起来像XML,但我写的XML解析器对此无能为力,因为括号不仅有一个像normale xml这样的单词。

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

So what would be a good way in objective-c to split this string into a logic structure?

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

Thanks for your help!

谢谢你的帮助!

1 个解决方案

#1


0  

If you replace the \" marks with ", it parses as fully valid XML. I think that's your only problem.

如果替换“标记”,它将解析为完全有效的XML。我认为那是你唯一的问题。

#1


0  

If you replace the \" marks with ", it parses as fully valid XML. I think that's your only problem.

如果替换“标记”,它将解析为完全有效的XML。我认为那是你唯一的问题。