Help needed with simple but strangely formatted feed

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.

With SimpleXML, you can just cast the element’s variable to a string; either explicitly by doing (string) $info or automatically when echoing like echo $info.

A good place to get to grips with how SimpleXML does things (which is a little strange, at times) is on the manual page detailing its basic usage. (:

P.S. In your example above, you use $slot (rather than $info) for the name attribute.

Thanks Salathe - for both the reply and the link. I’ve been looking for a good resource for XML/PHP for a while, so I’ll certainly have a read through that link.

So with the XML example above, does that mean I just need to call $game to access the unformatted number?

Thanks again