我该如何使用touchXML解析这个XML?我想将所有属性存储为键/值对在一个字典中。
<Player PlayerName="Padraig HARRINGTON" CurrentPosition="1" CurrentRank="1"
Country="IRL" NumberOfHolesPlayed="18" ParRelativeScore="+3">
<RoundScore RoundNumber="1" Score="74" />
<RoundScore RoundNumber="2" Score="68" />
<RoundScore RoundNumber="3" Score="72" />
<RoundScore RoundNumber="4" Score="69" />
</Player>
<Player PlayerName="Ian POULTER" CurrentPosition="2" CurrentRank="2" Country="ENG"
NumberOfHolesPlayed="18" ParRelativeScore="+7">
<RoundScore RoundNumber="1" Score="72" />
<RoundScore RoundNumber="2" Score="71" />
<RoundScore RoundNumber="3" Score="75" />
<RoundScore RoundNumber="4" Score="69" />
</Player>
<Player PlayerName="Henrik STENSON" CurrentPosition="3" CurrentRank="T3" Country="SWE"
NumberOfHolesPlayed="18" ParRelativeScore="+9">
<RoundScore RoundNumber="1" Score="76" />
<RoundScore RoundNumber="2" Score="72" />
<RoundScore RoundNumber="3" Score="70" />
<RoundScore RoundNumber="4" Score="71" />
</Player>
如果XML格式如下,我没有问题:
<Player>
<Country>UK</Country>
<NumberOfHolesPlayed>12</NumberOfHolesPlayed>
...
...
但是我不确定在处理属性时该怎么办...
如何使用touchXML获取属性?特别是如果一个节点有一个子节点也有属性的情况下..
根据第一个示例XML文件。在第一个XML示例中,我成功获取了Player属性,但没有获取到子节点'RoundScore'属性。
希望能得到帮助。
谢谢,
Dan