Advertisement
Guest User

Amino.dk - Hjælp til XML fil

a guest
Nov 14th, 2011
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. <?php
  2. $data = file_get_contents("http://spasserbussen.dk/all.xml");
  3. $xml = new SimpleXMLElement($data);
  4. $games = $xml->games;
  5.  
  6. if (!isset($_GET['game'])) {  
  7.     echo('<h1>Spil</h1>');
  8.  
  9.     foreach($games->game as $game) {
  10.         $thumb = $game->images->thumb;
  11.         $title = $game->title;
  12.         $url = urlencode($title);
  13.  
  14.         echo <<< EOF
  15.             <div class='game'>
  16.                 <a href='?game=$url'><img src='$thumb' /><br />
  17.                 <b>$title</b></a>
  18.             </div>
  19. EOF;
  20.     }
  21. } else {
  22.     $title = urldecode($_GET['game']);
  23.    
  24.     $game = $games->xpath('game/title[text()="' . $title . '"]/..');
  25.     $game = $game[0];
  26.    
  27.     $title = $game->title;
  28.     $description = $game->description;
  29.     $swf = $game->swf;
  30.     $width = $game->width;
  31.     $height = $game->height;
  32.    
  33.     echo <<< EOF
  34.         <h1>$title</h1>
  35.         <p>$description</p>
  36.            
  37.         <!--[if !IE]> -->
  38.         <object type="application/x-shockwave-flash"
  39.           data="$swf" width="$width" height="$height">
  40.         <!-- <![endif]-->
  41.  
  42.         <!--[if IE]>
  43.         <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  44.           codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"
  45.           width="$width" height="$height">
  46.           <param name="movie" value="$swf" />
  47.         <!--><!--dgx-->
  48.         <param name="loop" value="true" />
  49.         <param name="menu" value="false" />
  50.  
  51.           <p>This is <b>alternative</b> content.</p>
  52.         </object>
  53.         <!-- <![endif]-->
  54. EOF;
  55. }
  56. ?>
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement