Evening everyone - believe it or not my XML skills are improving, but I’ve come across a strangely formatted XML feed, and I can’t seem to get all the information I want.
The feed looks like this:
<sport>
<game name=“Cricket” url=“mydomain.com/cricket” viewers=“46271” ticketFormatted=“$1,667,594.65”>1667594.65</game>
<sport>
I’ve written the following script to extract the url, viewers, and ticketFormatted attributes and it’s working fine:
$url= "www.feeddomain.com";
$xml = simplexml_load_file( $url);
foreach( $xml->game as $info){
//insert query into database
if ( !mysql_query('INSERT INTO progressives (game, ticket, url)
VALUES ("'.$info['name'].'", "'.$info['ticketFormatted'].'", "'.$info['url'].'")'))
{
echo 'Problem with <strong>'.$slot['name'].'</strong>: '. mysql_error().'<br />';
}
}
However, rather than extracing the ticketFormatted figure, I’d really like to extract the ‘unformatted’ figure - the number which is effectively the value of ‘game’ (1667594.65) in the example above
So my question is, given that my loop currently extracts all the different attributes of ‘game’ into an array, what’s the best way of extracting the value of the ‘game’ node generally which obviously isn’t an attribute?
I hope I’ve explained that clearly, but if you need me to explain further, do please ask any questions.
Thanks a lot for your help in advance.