I have this xml:
<events>
<event>
<eventId>Bskt-Bulls-Pacer-042111</eventId>
<eventDescriptor></eventDescriptor>
<eventStatus></eventStatus>
<markets>
<market>
<lineType>PSH</lineType>
<status>1</status>
<num>100</num>
<den>110</den>
<points>4.0</points>
<quickbet></quickbet>
<price>-110</price>
<openNum>100</openNum>
<openDen>110</openDen>
<openPoints>-5.0</openPoints>
<openPrice>-110</openPrice>
<percentage>23%</percentage>
</market>
<market></market>
<market></market>
<market>
<lineType>PSA</lineType>
<status>1</status>
<num>100</num>
<den>110</den>
<points>-4.0</points>
<quickbet>
selection[Bskt-Bulls-Pacer-042111PSA]=Bskt-Bulls-Pacer-042111|PSA|1|100|110|-8|-110
</quickbet>
<price>-110</price>
<openNum>100</openNum>
<openDen>110</openDen>
<openPoints>5.0</openPoints>
<openPrice>-110</openPrice>
<percentage>77%</percentage>
</market>
<market></market>
<market></market>
</markets>
<hosturl></hosturl>
</event>
<event></event>
<event></event>
<event></event>
<event></event>
<event></event>
<event></event>
<event></event>
</events>
I'm stuck trying to pull out only <points>
from market when lineType = PSA and TLO. I need to pull this from multiple <event>
nodes. How do I test lineType in <market>
in each <event>
and pull out the ones I want?
This is what I have, but clearly isn't working:
foreach ($xml->event as $event) {
foreach ($xml->event->markets->market as $market) {
if ($market->lineType == 'TLO') {
echo "points are TLO = " . $market->points;
}
if ($market->lineType == 'PSH') {
echo "points are PSA = " . $market->points;
}
}
}