I need to parse the linked XML. How would I select a dynamic tag (in this case _0F2E09D773BD4A4B9B9F74D7A8B99A51) and echo damagedealt for Blood_Wolf89?
Asked
Active
Viewed 53 times
-1
-
SimpleXML will be your friend in this case. http://php.net/manual/en/simplexml.examples-basic.php – RonnieT Oct 26 '16 at 02:04
-
1) Thank you, I have been looking at SimpleXML. I am having issues figuring out how to get the data from the dynamic tag. – Blood_Wolf89 Oct 26 '16 at 02:11
1 Answers
1
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.

Deep
- 2,472
- 2
- 15
- 25
-
Thank you so much! Sofar I think I am good now. I may need more help in the near future. If I do I will post it here. Again, Thank you! – Blood_Wolf89 Oct 26 '16 at 02:23
-
Oh I have a question, How would I get the data in _8B00F0222E98407E9637D5573F929B24? For example gamemode="3" or matchtype="pve" – Blood_Wolf89 Oct 26 '16 at 02:28
-
1Questions, questions,questions... This is easy. I think you should look here http://www.w3schools.com/xml/xpath_intro.asp – Deep Oct 26 '16 at 02:33
-
Thank you so much! I almost skipped dinner because I am now on a role thanks to you! I have done stuff with json and I thought it would be similar.. Ok Back to work for me! hahaha – Blood_Wolf89 Oct 26 '16 at 03:07
-
I can not figure out how I would dynamically echo the node name and namespace from this.. http://pastebin.com/YKeXnDUs – Blood_Wolf89 Oct 26 '16 at 09:21
-
One more question, is there a way to search for a child while knowing part of the name? – Blood_Wolf89 Oct 31 '16 at 03:31
-
1