I have an XML which looks like the following:
$data = '<search-params>
<date>2013-05-20</date>
</search-params>
<results>
<date>2013-05-21 14:31:00</date>
<prices>
<for>
<players>1</players>
</for>
<amount>20</amount>
</prices>
<prices>
<for>
<players>2</players>
</for>
<amount>35</amount>
</prices>
<prices>
<for>
<players>3</players>
</for>
<amount>49.5</amount>
</prices>
<prices>
<for>
<players>4</players>
</for>
<amount>60</amount>
</prices>
</results>
<results>
<date>2013-05-21T14:40:00</date>
<prices>
<for>
<players>1</players>
</for>
<amount>20</amount>
</prices>
</results>';
Now, what I want to do is to strip out some of that based on a rule.
So, If I have <players>
child node of 4, it should only return the <results>
nodes that have that value.
Is this possible in in PHP?
I can load that using simplexml_load_string($data)
. The problem is how to find the information and remove the nodes.
Thanks