Jump to content

Recommended Posts

Ok so this link returns HTML

 

$hitlist = file_get_contents($iMobLink."get_hit_list?user_id=".$iStore[2]."&level=10&auth_key=".$iStore[3]);

 

now to parse it out I have this

 

	$entry = explode('<entry>', $hitlist);
$hitlist = file_get_contents($iMobLink."get_hit_list?user_id=".$iStore[2]."&level=10&auth_key=".$iStore[3]);
    $user_id = explode('<user_id>', $hitlist);
$user_id = explode('</user_id>', $user_id[1]);
$mobname = explode('<mob_name>', $hitlist);
$mobname = explode('</mob_name>', $mobname[1]);
$paiduser = explode('<paid_user>', $hitlist);
$paiduser = explode('</paid_user>', $paid_user[1]);
    $amount = explode('<amount>', $hitlist);
$amount = explode('</amount>', $amount[1]);
$paid_time = explode('<placed_time_ago>', $hitlist);
$paid_time = explode('</placed_time_ago>', $paid_time[1]);
$level = explode('<level>', $hitlist);
$level = explode('</level>', $level[1]);
$entry = explode('</entry>', $entry[1]);
echo $user_id[0]."\n";
echo urldecode($mobname[0])."\n";
echo $amount[0]."\n";
echo $paid_time[0]."\n";
echo $level[0]."\n";
echo $entry[0];}	

 

Ok now.... this only returns one entry of the xml when there are more than 10. I need it to return all ten+ of the entrys

 

here is what the xml looks like

 

<outer>

<xml>

<entry>

<target_user>

<user_id>512433892</user_id>

<mob_name>MR%2025TATT00S%2C%20Level%2015</mob_name>

</target_user>

<paid_user>

<user_id>554190549</user_id>

<mob_name>PRINCE%20OF%20NEW</mob_name>

</paid_user>

<amount>48000000000</amount>

<is_npc>false</is_npc>

<placed_time_ago>3 days ago</placed_time_ago>

<level>15</level>

</entry>

<entry>

<target_user>

<user_id>530120192</user_id>

<mob_name>EVILNESS%20SIMPLIFIED%2C%20Level%2013</mob_name>

</target_user>

<paid_user>

<user_id>539494114</user_id>

<mob_name>StompinDatAzz</mob_name>

</paid_user>

<amount>1478608800</amount>

<is_npc>false</is_npc>

<placed_time_ago>1 day ago</placed_time_ago>

<level>13</level>

</entry>

<entry>

<target_user>

<user_id>526183645</user_id>

<mob_name>snatch%20rider%2C%20Level%20112</mob_name>

</target_user>

<paid_user>

<user_id>450207248</user_id>

<mob_name>ShiftyShellShock</mob_name>

</paid_user>

<amount>999999999</amount>

<is_npc>false</is_npc>

<placed_time_ago>22 hours ago</placed_time_ago>

<level>112</level>

</entry>

<entry>

<target_user>

<user_id>542145086</user_id>

<mob_name>Riding%20Raider%2C%20Level%2043</mob_name>

</target_user>

<paid_user>

<user_id>513441119</user_id>

<mob_name>Level%20U%20uP</mob_name>

</paid_user>

<amount>334616000</amount>

<is_npc>false</is_npc>

<placed_time_ago>18 hours ago</placed_time_ago>

<level>43</level>

</entry>

<entry>

<target_user>

<user_id>554043828</user_id>

<mob_name>klaibers%20limited%2C%20Level%2011</mob_name>

</target_user>

<paid_user>

<user_id>522432052</user_id>

<mob_name>Sloppy%20Seconds</mob_name>

</paid_user>

<amount>39344504405</amount>

<is_npc>false</is_npc>

<placed_time_ago>17 hours ago</placed_time_ago>

<level>11</level>

</entry>

<entry>

<target_user>

<user_id>496266215</user_id>

<mob_name>Geheim%20Abwher%2C%20Level%207</mob_name>

</target_user>

<paid_user>

<user_id>216904061</user_id>

<mob_name>yve1</mob_name>

</paid_user>

<amount>2499912800</amount>

<is_npc>false</is_npc>

<placed_time_ago>16 hours ago</placed_time_ago>

<level>7</level>

</entry>

<entry>

<target_user>

<user_id>524874924</user_id>

<mob_name>MYLILFRIEND%2C%20Level%20104</mob_name>

</target_user>

<paid_user>

<user_id>536745842</user_id>

<mob_name>SUC%20MY%20GLOCK</mob_name>

</paid_user>

<amount>1615247200</amount>

<is_npc>false</is_npc>

<placed_time_ago>15 hours ago</placed_time_ago>

<level>104</level>

</entry>

<entry>

<target_user>

<user_id>531185082</user_id>

<mob_name>THE%20RAGE%20WITHIN%2C%20Level%2031</mob_name>

</target_user>

<paid_user>

<user_id>512862859</user_id>

<mob_name>The%20Kozmik%20Slop</mob_name>

</paid_user>

<amount>16536800</amount>

<is_npc>false</is_npc>

<placed_time_ago>14 hours ago</placed_time_ago>

<level>31</level>

</entry>

<entry>

<target_user>

<user_id>494326270</user_id>

<mob_name>RIDE%20HIS%20CUCUMBER%2C%20Level%2016</mob_name>

</target_user>

<paid_user>

<user_id>554794332</user_id>

<mob_name>STDS%20R%20BAD%20MMKAY</mob_name>

</paid_user>

<amount>337825600</amount>

<is_npc>false</is_npc>

<placed_time_ago>14 hours ago</placed_time_ago>

<level>16</level>

</entry>

<entry>

<target_user>

<user_id>558355598</user_id>

<mob_name>DEATH%20TO%20HITLIST%2C%20Level%2011</mob_name>

</target_user>

<paid_user>

<user_id>558349535</user_id>

<mob_name>Gangsta%20Love</mob_name>

</paid_user>

<amount>181600000</amount>

<is_npc>false</is_npc>

<placed_time_ago>10 hours ago</placed_time_ago>

<level>11</level>

</entry>

<entry>

<target_user>

<user_id>545114043</user_id>

<mob_name>Ridin%20Dirty%2C%20Level%20130</mob_name>

</target_user>

<paid_user>

<user_id>510805692</user_id>

<mob_name>iced%20baby</mob_name>

</paid_user>

<amount>481680800</amount>

<is_npc>false</is_npc>

<placed_time_ago>10 hours ago</placed_time_ago>

<level>130</level>

</entry>

 

Notice there is more than one energy.. now how to I parse it out to where I can define each entry by a variable or something... any help is appreciated.. Thanks

Link to comment
https://forums.phpfreaks.com/topic/222224-help-with-arrays-and-xml/
Share on other sites

Take a look at this:

http://www.phpfreaks.com/forums/php-coding-help/count-xml-child-elements-and-generate-html-table/msg1501644/#msg1501644

 

You can use that as a starting point to learn how to use xpath and loop through the elements.

Specific to your data -

<?php
$hitlist = file_get_contents($iMobLink."get_hit_list?user_id=".$iStore[2]."&level=10&auth_key=".$iStore[3]);

$xml = simplexml_load_string($hitlist);
//echo '<pre>',print_r($xml,true),'</pre>'; // view the data

foreach($xml->entry as $node){
echo "User id: {$node->target_user->user_id}<br />";
echo "Mob name: ". urldecode($node->target_user->mob_name) . "<br />";
echo "Amount: {$node->amount}<br />";
echo "Time: {$node->placed_time_ago}<br />";
echo "Level: {$node->level}<br /><br />";
}
?>

Sounds like your file_get_contents() is not reading anything (I tested with the data that you posted, fixed to make it valid xml.)

 

Are you doing this on a system with error_reporting set to E_ALL (or a -1) and display_errors set to ON so that all the php detected errors would be reported and displayed?

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.