Load just XPath search to XMLReader memory?

261 views Asked by At

Can i somehow do this? XMLReader is pull parser, so i expect from him to give me just data i search, but it loads whole document into memory and then gives me search from his memory.

This code:

$url = $this->buildUrl($name,$params);   
    $xml = '';

    $reader = new XMLReader();
    $reader->open($url);
    $pathXML = '';
    $dom = new DomDocument();

    while($reader->read()) {
        if ($reader->nodeType == XMLREADER::ELEMENT && $reader->localName == 'OddsList'){
             $xml = simplexml_import_dom($dom->importNode($reader->expand(),true));
             if(!is_null($this->getExpression())){
                $pathXML = $xml->xpath($this->getExpression());
             }
        break;
        }

    }

    var_dump($pathXML);

returns me this:

string '' (length=0)
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '346213' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T01:42:35.243' (length=23)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '1.8' (length=3)
      public 'AwayOdds' => string '1.8' (length=3)
  1 => 
    object(SimpleXMLElement)[15]
      public 'FixtureMatch_Id' => string '346213' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T01:42:33.497' (length=23)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '1.6' (length=3)
      public 'DrawOdds' => string '3.6' (length=3)
      public 'AwayOdds' => string '5' (length=1)
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '346215' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:42:45.99' (length=22)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '1.85' (length=4)
      public 'AwayOdds' => string '1.75' (length=4)
  1 => 
    object(SimpleXMLElement)[11]
      public 'FixtureMatch_Id' => string '346215' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:42:44.223' (length=23)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '2.5' (length=3)
      public 'DrawOdds' => string '3.2' (length=3)
      public 'AwayOdds' => string '2.6' (length=3)
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '346489' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:43:53.027' (length=23)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '2.2' (length=3)
      public 'AwayOdds' => string '1.55' (length=4)
  1 => 
    object(SimpleXMLElement)[12]
      public 'FixtureMatch_Id' => string '346489' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:43:51.12' (length=22)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '2' (length=1)
      public 'DrawOdds' => string '3' (length=1)
      public 'AwayOdds' => string '3.4' (length=3)
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '348052' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:44:07.743' (length=23)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '1.95' (length=4)
      public 'AwayOdds' => string '1.65' (length=4)
  1 => 
    object(SimpleXMLElement)[13]
      public 'FixtureMatch_Id' => string '348052' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:44:05.55' (length=22)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '2.85' (length=4)
      public 'DrawOdds' => string '3.1' (length=3)
      public 'AwayOdds' => string '2.3' (length=3)
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '348053' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:44:00.293' (length=23)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '1.75' (length=4)
      public 'AwayOdds' => string '1.85' (length=4)
  1 => 
    object(SimpleXMLElement)[11]
      public 'FixtureMatch_Id' => string '348053' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:43:58.543' (length=23)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '2' (length=1)
      public 'DrawOdds' => string '3.25' (length=4)
      public 'AwayOdds' => string '3.35' (length=4)
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '348054' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:44:18.25' (length=22)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '1.9' (length=3)
      public 'AwayOdds' => string '1.7' (length=3)
  1 => 
    object(SimpleXMLElement)[12]
      public 'FixtureMatch_Id' => string '348054' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:44:16.453' (length=23)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '2.85' (length=4)
      public 'DrawOdds' => string '3.1' (length=3)
      public 'AwayOdds' => string '2.3' (length=3)
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '348055' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:44:13.057' (length=23)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '1.8' (length=3)
      public 'AwayOdds' => string '1.8' (length=3)
  1 => 
    object(SimpleXMLElement)[15]
      public 'FixtureMatch_Id' => string '348055' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:44:11.233' (length=23)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '1.65' (length=4)
      public 'DrawOdds' => string '3.5' (length=3)
      public 'AwayOdds' => string '4.45' (length=4)
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '348056' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:44:23.867' (length=23)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '1.8' (length=3)
      public 'AwayOdds' => string '1.8' (length=3)
  1 => 
    object(SimpleXMLElement)[13]
      public 'FixtureMatch_Id' => string '348056' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:44:22.053' (length=23)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '1.7' (length=3)
      public 'DrawOdds' => string '3.45' (length=4)
      public 'AwayOdds' => string '4.3' (length=3)
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '348260' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-20T19:43:01.34' (length=22)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '1.8' (length=3)
      public 'AwayOdds' => string '1.8' (length=3)
  1 => 
    object(SimpleXMLElement)[11]
      public 'FixtureMatch_Id' => string '348260' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-20T19:42:59.603' (length=23)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '2.6' (length=3)
      public 'DrawOdds' => string '3.2' (length=3)
      public 'AwayOdds' => string '2.5' (length=3)
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '348261' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:43:16.187' (length=23)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '2.2' (length=3)
      public 'AwayOdds' => string '1.55' (length=4)
  1 => 
    object(SimpleXMLElement)[12]
      public 'FixtureMatch_Id' => string '348261' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:43:14.417' (length=23)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '1.5' (length=3)
      public 'DrawOdds' => string '3.8' (length=3)
      public 'AwayOdds' => string '5.7' (length=3)
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '348262' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T01:43:06.497' (length=23)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '2.3' (length=3)
      public 'AwayOdds' => string '1.5' (length=3)
  1 => 
    object(SimpleXMLElement)[15]
      public 'FixtureMatch_Id' => string '348262' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T01:43:04.747' (length=23)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '1.9' (length=3)
      public 'DrawOdds' => string '3.3' (length=3)
      public 'AwayOdds' => string '3.7' (length=3)
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '348263' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:43:31.8' (length=21)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '1.8' (length=3)
      public 'AwayOdds' => string '1.8' (length=3)
  1 => 
    object(SimpleXMLElement)[13]
      public 'FixtureMatch_Id' => string '348263' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:43:30.017' (length=23)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '1.35' (length=4)
      public 'DrawOdds' => string '4.5' (length=3)
      public 'AwayOdds' => string '7.3' (length=3)
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '348264' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:43:26.353' (length=23)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '2.2' (length=3)
      public 'AwayOdds' => string '1.55' (length=4)
  1 => 
    object(SimpleXMLElement)[11]
      public 'FixtureMatch_Id' => string '348264' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:43:24.62' (length=22)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '1.9' (length=3)
      public 'DrawOdds' => string '3.3' (length=3)
      public 'AwayOdds' => string '3.7' (length=3)
array (size=2)
  0 => 
    object(SimpleXMLElement)[14]
      public 'FixtureMatch_Id' => string '348265' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:43:21.26' (length=22)
      public 'Type' => string 'Over/Under 2.5' (length=14)
      public 'HomeOdds' => string '2.4' (length=3)
      public 'AwayOdds' => string '1.45' (length=4)
  1 => 
    object(SimpleXMLElement)[12]
      public 'FixtureMatch_Id' => string '348265' (length=6)
      public 'Bookmaker' => string 'Interwetten' (length=11)
      public 'UpdatedDate' => string '2015-06-21T10:43:19.547' (length=23)
      public 'Type' => string '1X2' (length=3)
      public 'HomeOdds' => string '2.3' (length=3)
      public 'DrawOdds' => string '3.2' (length=3)
      public 'AwayOdds' => string '2.8' (length=3)
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty
array (size=0)
  empty

I want somehow to get just feeds where Bookmaker is Interwetten without loading others, just jump to Interwetten return me searched feed end. This takes much time.

XML structure is like this:

<XMLSOCCER.COM>
<OddsList>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Bet-At-Home</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:32.943</UpdatedDate>
  <Type>Over/Under 2.5</Type>
  <HomeOdds>2.22</HomeOdds>
  <AwayOdds>1.58</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Interwetten</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:33.113</UpdatedDate>
  <Type>Over/Under 2.5</Type>
  <HomeOdds>1.85</HomeOdds>
  <AwayOdds>1.75</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>188Bet</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:33.27</UpdatedDate>
  <Type>Over/Under 2.5</Type>
  <HomeOdds>2.11</HomeOdds>
  <AwayOdds>1.8</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Pinnacle</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:32.803</UpdatedDate>
  <Type>Over/Under 2.5</Type>
  <HomeOdds>2.33</HomeOdds>
  <AwayOdds>1.65</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Bet365</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:34.263</UpdatedDate>
  <Type>Handicap</Type>
  <HomeOdds>3.1</HomeOdds>
  <DrawOdds>3.5</DrawOdds>
  <AwayOdds>2</AwayOdds>
  <Handicap>-1</Handicap>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Bet-At-Home</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:34.373</UpdatedDate>
  <Type>Handicap</Type>
  <HomeOdds>1.17</HomeOdds>
  <DrawOdds>5.41</DrawOdds>
  <AwayOdds>10.32</AwayOdds>
  <Handicap>1</Handicap>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Mybet</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:34.5</UpdatedDate>
  <Type>Handicap</Type>
  <HomeOdds>3.35</HomeOdds>
  <DrawOdds>3.5</DrawOdds>
  <AwayOdds>1.85</AwayOdds>
  <Handicap>-1</Handicap>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Expekt</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:33.41</UpdatedDate>
  <Type>Double Chance</Type>
  <HomeOdds>1.15</HomeOdds>
  <DrawOdds>1.85</DrawOdds>
  <AwayOdds>1.3</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Bet-At-Home</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:33.787</UpdatedDate>
  <Type>Double Chance</Type>
  <HomeOdds>1.17</HomeOdds>
  <DrawOdds>1.8</DrawOdds>
  <AwayOdds>1.25</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Mybet</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:34.037</UpdatedDate>
  <Type>Double Chance</Type>
  <HomeOdds>1.15</HomeOdds>
  <DrawOdds>1.85</DrawOdds>
  <AwayOdds>1.25</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>BetClic</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:34.16</UpdatedDate>
  <Type>Double Chance</Type>
  <HomeOdds>1.15</HomeOdds>
  <DrawOdds>1.85</DrawOdds>
  <AwayOdds>1.3</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Unibet</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:33.52</UpdatedDate>
  <Type>Double Chance</Type>
  <HomeOdds>1.22</HomeOdds>
  <DrawOdds>1.84</DrawOdds>
  <AwayOdds>1.29</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>888</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:33.647</UpdatedDate>
  <Type>Double Chance</Type>
  <HomeOdds>1.22</HomeOdds>
  <DrawOdds>1.84</DrawOdds>
  <AwayOdds>1.29</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Pinnacle</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:34.733</UpdatedDate>
  <Type>Asian Handicap</Type>
  <HomeOdds>1.92</HomeOdds>
  <AwayOdds>2</AwayOdds>
  <Handicap>-0.5</Handicap>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>WilliamHill</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:34.623</UpdatedDate>
  <Type>Asian Handicap</Type>
  <HomeOdds>1.36</HomeOdds>
  <AwayOdds>3</AwayOdds>
  <Handicap>0</Handicap>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Betfred</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:34.86</UpdatedDate>
  <Type>Asian Handicap</Type>
  <HomeOdds>1.36</HomeOdds>
  <AwayOdds>3</AwayOdds>
  <Handicap>0</Handicap>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>188Bet</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:34.967</UpdatedDate>
  <Type>Asian Handicap</Type>
  <HomeOdds>1.89</HomeOdds>
  <AwayOdds>2.03</AwayOdds>
  <Handicap>-0.5</Handicap>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Doxxbet</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:31.63</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.85</HomeOdds>
  <DrawOdds>3.3</DrawOdds>
  <AwayOdds>3.92</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>BetSafe</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:30.74</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.84</HomeOdds>
  <DrawOdds>3.25</DrawOdds>
  <AwayOdds>4.25</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Pinnacle</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:30.257</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.92</HomeOdds>
  <DrawOdds>3.4</DrawOdds>
  <AwayOdds>4.8</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>888</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:31.02</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.9</HomeOdds>
  <DrawOdds>3.4</DrawOdds>
  <AwayOdds>4</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Skybet</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:32.177</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.91</HomeOdds>
  <DrawOdds>3.4</DrawOdds>
  <AwayOdds>4</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>WilliamHill</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:29.91</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.91</HomeOdds>
  <DrawOdds>3.3</DrawOdds>
  <AwayOdds>4.33</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Bet365</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:30.02</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.83</HomeOdds>
  <DrawOdds>3.4</DrawOdds>
  <AwayOdds>4.5</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Expekt</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:30.13</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.82</HomeOdds>
  <DrawOdds>3.1</DrawOdds>
  <AwayOdds>4.6</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Betfred</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:30.473</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.83</HomeOdds>
  <DrawOdds>3.3</DrawOdds>
  <AwayOdds>4.33</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Bet-At-Home</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:31.13</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.82</HomeOdds>
  <DrawOdds>3.18</DrawOdds>
  <AwayOdds>4.25</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Interwetten</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:31.397</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.8</HomeOdds>
  <DrawOdds>3.4</DrawOdds>
  <AwayOdds>4</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>BWin</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:31.77</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.85</HomeOdds>
  <DrawOdds>3.3</DrawOdds>
  <AwayOdds>3.9</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Mybet</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:31.943</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.85</HomeOdds>
  <DrawOdds>3.3</DrawOdds>
  <AwayOdds>4</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>BetClic</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:32.067</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.82</HomeOdds>
  <DrawOdds>3.1</DrawOdds>
  <AwayOdds>4.6</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>188Bet</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:32.27</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.86</HomeOdds>
  <DrawOdds>3.15</DrawOdds>
  <AwayOdds>4.05</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>10Bet</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:32.473</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.83</HomeOdds>
  <DrawOdds>3.2</DrawOdds>
  <AwayOdds>4.4</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Sportingbet</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:32.707</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.83</HomeOdds>
  <DrawOdds>3.25</DrawOdds>
  <AwayOdds>4.33</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>NordicBet</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:30.63</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.84</HomeOdds>
  <DrawOdds>3.25</DrawOdds>
  <AwayOdds>4.25</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Ladbrokes</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:30.85</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.85</HomeOdds>
  <DrawOdds>3.1</DrawOdds>
  <AwayOdds>4.25</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>Unibet</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:30.38</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.9</HomeOdds>
  <DrawOdds>3.4</DrawOdds>
  <AwayOdds>4</AwayOdds>
</Odds>
<Odds>
  <FixtureMatch_Id>346076</FixtureMatch_Id>
  <Bookmaker>5Dimes</Bookmaker>
  <UpdatedDate>2015-06-20T19:42:31.507</UpdatedDate>
  <Type>1X2</Type>
  <HomeOdds>1.92</HomeOdds>
  <DrawOdds>3.4</DrawOdds>
  <AwayOdds>4.8</AwayOdds>
</Odds>
</OddsList>
1

There are 1 answers

0
mhall On BEST ANSWER

You are still searching the entire OddsList. Try using the XMLReader something like this:

$reader = new XMLReader();
$reader->open($url);
$dom = new DomDocument();

// Find first occurrence of Odds
while ($reader->read() && $reader->name !== 'Odds');

// Iterate Odds
while ($reader->name === 'Odds'){
    $odds = simplexml_import_dom($dom->importNode($reader->expand(), true));

    // Process those having the correct Bookmaker child value
    if ($odds->xpath('./Bookmaker[string()="Interwetten"]')) {
        var_dump($odds);
    }

    // Move to the next one
    $reader->next('Odds');
}

Output:

object(SimpleXMLElement)#4 (6) {
  ["FixtureMatch_Id"]=>
  string(6) "346076"
  ["Bookmaker"]=>
  string(11) "Interwetten"
  ["UpdatedDate"]=>
  string(23) "2015-06-20T19:42:33.113"
  ["Type"]=>
  string(14) "Over/Under 2.5"
  ["HomeOdds"]=>
  string(4) "1.85"
  ["AwayOdds"]=>
  string(4) "1.75"
}
object(SimpleXMLElement)#4 (7) {
  ["FixtureMatch_Id"]=>
  string(6) "346076"
  ["Bookmaker"]=>
  string(11) "Interwetten"
  ["UpdatedDate"]=>
  string(23) "2015-06-20T19:42:31.397"
  ["Type"]=>
  string(3) "1X2"
  ["HomeOdds"]=>
  string(3) "1.8"
  ["DrawOdds"]=>
  string(3) "3.4"
  ["AwayOdds"]=>
  string(1) "4"
}