Scummy12 Posted September 20, 2010 Share Posted September 20, 2010 http://mobsters-fb-apache-dynamic-lb.playdom.com/mob_fb/get_hit_list?user_id=100000952273457&target_id=100000556624340&level=300&auth_key=cb07c7575b38df48d82dd53619385faa884db5a2 When going to this URL, it gives entries between <entry> and </entry>, what I am trying to do, is collect the <user_id> ONLY if the <amount> is over a certain value. Any ideas to how I could do this (I am a complete PHP noob). All help is appreciated Link to comment https://forums.phpfreaks.com/topic/213863-splitting/ Share on other sites More sharing options...
Adam Posted September 20, 2010 Share Posted September 20, 2010 You can do that using the SimpleXML extension: $url = 'http://mobsters-fb-apache-dynamic-lb.playdom.com/mob_fb/get_hit_list?user_id=100000952273457&target_id=100000556624340&level=300&auth_key=cb07c7575b38df48d82dd53619385faa884db5a2'; $xml = new SimpleXMLElement($url, null, true); foreach ($xml->xpath('/outer/xml/entry') as $entry) { if ($entry->amount > 4100000000) { echo 'Targeted user: ' . $entry->target_user->user_id . '<br />'; } } Link to comment https://forums.phpfreaks.com/topic/213863-splitting/#findComment-1113164 Share on other sites More sharing options...
ignace Posted September 20, 2010 Share Posted September 20, 2010 MrAdam was on the right track but you can add conditionals to XPath: $url = 'http://mobsters-fb-apache-dynamic-lb.playdom.com/mob_fb/get_hit_list?user_id=100000952273457&target_id=100000556624340&level=300&auth_key=cb07c7575b38df48d82dd53619385faa884db5a2'; $xml = new SimpleXMLElement($url, null, true); foreach ($xml->xpath('/outer/xml[entry > 4100000000]') as $entry) { echo 'Targeted user: ' . $entry->target_user->user_id . '<br />'; } Link to comment https://forums.phpfreaks.com/topic/213863-splitting/#findComment-1113181 Share on other sites More sharing options...
Adam Posted September 20, 2010 Share Posted September 20, 2010 Edit: oh yeah it will $url = 'http://mobsters-fb-apache-dynamic-lb.playdom.com/mob_fb/get_hit_list?user_id=100000952273457&target_id=100000556624340&level=300&auth_key=cb07c7575b38df48d82dd53619385faa884db5a2'; $xml = new SimpleXMLElement($url, null, true); foreach ($xml->xpath('/outer/xml/entry[amount > 4100000000]') as $entry) { echo 'Targeted user: ' . $entry->target_user->user_id . '<br />'; } Link to comment https://forums.phpfreaks.com/topic/213863-splitting/#findComment-1113182 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.