class GameDesc { var $Name = ""; var $Description = ""; var $File = ""; } $games = array(); $games[0] = new GameDesc(); $games[0]->Name = "Snake"; $games[0]->Description = "A game with a snake thingy you have to move around. Don't hit your tail!"; $games[0]->File = "Snake.zip"; $games[1] = new GameDesc(); $games[1]->Name = "RPG"; $games[1]->Description = "A demo RPG!"; $games[1]->File = "RPG.zip"; $games[2] = new GameDesc(); $games[2]->Name = "Shooter"; $games[2]->Description = "A game where you shoot people up and shit."; $games[2]->File = "Shooter.zip"; $doc = new DOMDocument(); $doc->formatOutput = true; $r = $doc->createElement("games"); $doc->appendChild($r); foreach ($games as $game) { $b = $doc->createElement("game"); $name = $doc->createElement("name"); $name->appendChild($doc->createTextNode($game->Name)); $b->appendChild($name); $name = $doc->createElement("description"); $name->appendChild($doc->createTextNode($game->Description)); $b->appendChild($name); $name = $doc->createElement("file"); $name->appendChild($doc->createTextNode($game->File)); $b->appendChild($name); $r->appendChild( $b ); } echo "<xmp>"; echo $doc->saveXML(); echo "</xmp>"; $ourFileName = "test2.xml"; $ourFileHandle = fopen($ourFileName, 'w') or die ("Can't open file"); fwrite($ourFileHandle, $doc->saveXML()); fclose($ourFileHandle);/// CREATES --><?xml version="1.0"?><games> <game> <name>Snake</name> <description>A game with a snake thingy you have to move around. Don't hit your tail!</description> <file>Snake.zip</file> </game> <game> <name>RPG</name> <description>A demo RPG!</description> <file>RPG.zip</file> </game> <game> <name>Shooter</name> <description>A game where you shoot people up and shit.</description> <file>Shooter.zip</file> </game></games>