Jump to content

Parsing XML attribute with xpath() // Im too close, Need Help,


jwin27

Recommended Posts

hi, im trying to parse this xml  file : 

xml.gamebookers.com/sport /football.xml_attr.xml

 

i want to echo on my page like this :

 

league name 1

match 1 of league 1

odds odds odds

match 2 of league 1

odds odds odds

.

.

league name 2

match 1 of league 2

odds odds odds

match2 of league 2

odds odds odds

.

.

 

 

this is my code so far

<?php
$xml=simplexml_load_file('http://xml.gamebookers.com/sports/football.xml_attr.xml');

$league=$xml->xpath('//event/..');             // leagues refers to element<group> 
$matches=$xml->xpath('//bettype[@name="Versus (with Draw)"]/..'); // shows matches name (team versus team)
$odds=$xml->xpath('//event/bettype[@name="Versus (with Draw)"]/bet'); //odds of matches 1 x 2


$leaguecount=count($league);
$matchescount=count($matches);
$oddscount=count($odds);

$i=0;

while ($i<$leaguecount){
echo $league[$i]['name'].'<br>';
$i++;
}

echo '<br><br>';

$i=0;
while ($i<$matchescount){
echo $matches[$i]['name'].'<br>';
$i++;
}

$i=0;
while ($i<$oddscount){
echo $odds[$i]['odd'].'<br>';
$i++;
}

?>

 

it prints this:

http://www.mh724.com/school/xp.php

 

so i need something like that:

echo league[$i][mathces[$i][odds[$i]  // like arrays of array but it does not work of course

 

any help will highly appreciated  :shrug:

 

with regardS

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.