Jump to content

Splitting


Scummy12

Recommended Posts

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

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

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

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

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.