我想使用Microsoft Excel的FILTERXML函数从XML表单中获取数据。XPath“节点中有多少个元素?”与Microsoft EXCEL
我不太清楚为什么我使用某些XPath参数时无法获得数字响应。
这里是我的XML:
<result>
<status>1</status>
<num_results>1</num_results>
<total_results>500</total_results>
<results_remaining>499</results_remaining>
<matches>
<match>
<radiant_team_id>0</radiant_team_id>
<dire_team_id>0</dire_team_id>
<players>
<player>
<account_id>141684701</account_id>
<player_slot>0</player_slot>
<hero_id>0</hero_id>
</player>
<player>
<account_id>4294967295</account_id>
<player_slot>1</player_slot>
<hero_id>0</hero_id>
</player>
<player>
<account_id>4294967295</account_id>
<player_slot>2</player_slot>
<hero_id>0</hero_id>
</player>
</players>
</match>
</matches>
</result>
我试图用这个XPath的参数计算有多少玩家在每一个刷新的XML表单,以便ofter动态API弹出。玩家数从0-10变化。
/result/matches/match/players[count(player)]
我得到#!VALUE错误。这里是我使用的MS Excel函数参数:
=FILTERXML($A$2,"/result/matches/match/players/player[count(player)]")
这两个参数都失败了。有没有办法通过报告MS Excel中的另一个单元来报告XML表单中存在多少个播放器元素?
你想要做的正确的XPath是'count(/ result/matches/match/players/player)',但看起来像FILTERXML可能只允许XPath计算节点集(和' count()'求值到一个数字 – JLRishe 2014-10-20 05:44:07