Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <?php  
  2.     $xml = new DOMDocument();
  3.     $xml->load('merchant.xml');
  4.     foreach ($xml->documentElement->getElementsByTagName('itemlist') as $tag) {
  5.         $listid = $tag->getAttribute('listid');
  6.        
  7.         foreach ($tag->getElementsByTagName('item') as $list) {
  8.             $out[$listid][$list->getAttribute('id')] = array(
  9.                 //'id' => $list->getAttribute('id'),
  10.                 //'keywords' => explode(";", $list->getAttribute('keywords')),
  11.                 'keywords' => str_replace(';', ' ', $list->getAttribute('keywords')),
  12.                 'sellprice' => $list->getAttribute('sellprice'),
  13.                 'buyprice' => $list->getAttribute('buyprice'),
  14.                 'subtype' => $list->getAttribute('subtype'),
  15.                 'description' => $list->getAttribute('name'),
  16.                 'plural' => $list->getAttribute('pname'),
  17.             );
  18.         }
  19.     }
  20.    
  21.     foreach ($out as $k => $npc) {
  22.         foreach ($npc as $desc => $values) {
  23.             if ($desc) {
  24.                 echo "Item: ".$desc;
  25.                
  26.                 if ($values['keywords'])
  27.                     echo "<li>Keywords: ".$values['keywords']."</li>";
  28.                
  29.                 if ($values['sellprice'])
  30.                     echo "<li>Sell Price: ".$values['sellprice']."</li>";
  31.                    
  32.                 if ($values['buyprice'])
  33.                     echo "<li>Buy Price: ".$values['buyprice']."</li>";
  34.                    
  35.                 if ($values['description'])
  36.                     echo "<li>Description: ".$values['description']."</li>";
  37.                    
  38.                 echo "<br />";
  39.                
  40.             }
  41.         }
  42.     }
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement