Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.