echo selected data in php from xml [closed]

2019-06-14 18:38发布

I need to parse the linked XML. How would I select a dynamic tag (in this case _0F2E09D773BD4A4B9B9F74D7A8B99A51) and echo damagedealt for Blood_Wolf89?

Pastebin to xml data

标签: php xml parsing
1条回答
2楼-- · 2019-06-14 18:43

Just one line:

echo simplexml_load_file('test.xml')->xpath("//*[@playername='Blood_Wolf89'][ancestor::_0F2E09D773BD4A4B9B9F74D7A8B99A51]")[0]['damagedealt'];

But this require known tag name of ancestor. Because without ancestor you have many Blood_Wolf89 results.

查看更多
登录 后发表回答