Blood_Wolf89 Blood_Wolf89 - 1 month ago 6
PHP Question

echo selected data in php from xml

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

Answer

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.

Comments