Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $xml = new DOMDocument();
- $xml->load('merchant.xml');
- foreach ($xml->documentElement->getElementsByTagName('itemlist') as $tag) {
- $listid = $tag->getAttribute('listid');
- foreach ($tag->getElementsByTagName('item') as $list) {
- $out[$listid][$list->getAttribute('id')] = array(
- //'id' => $list->getAttribute('id'),
- //'keywords' => explode(";", $list->getAttribute('keywords')),
- 'keywords' => str_replace(';', ' ', $list->getAttribute('keywords')),
- 'sellprice' => $list->getAttribute('sellprice'),
- 'buyprice' => $list->getAttribute('buyprice'),
- 'subtype' => $list->getAttribute('subtype'),
- 'description' => $list->getAttribute('name'),
- 'plural' => $list->getAttribute('pname'),
- );
- }
- }
- foreach ($out as $k => $npc) {
- foreach ($npc as $desc => $values) {
- if ($desc) {
- echo "Item: ".$desc;
- if ($values['keywords'])
- echo "<li>Keywords: ".$values['keywords']."</li>";
- if ($values['sellprice'])
- echo "<li>Sell Price: ".$values['sellprice']."</li>";
- if ($values['buyprice'])
- echo "<li>Buy Price: ".$values['buyprice']."</li>";
- if ($values['description'])
- echo "<li>Description: ".$values['description']."</li>";
- echo "<br />";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement