Tolong pilih kategori sesuai, jenis posting (diskusi atau bukan) dan sertakan tag/topik yang sesuai seperti komputer, java, php, mysql, dll. Promosi atau posting tidak pada tempatnya akan kami hapus!
- Bagi Anda yang ingin mendaftar, baca link berikut:
http://diskusiweb.com/discussion/50491/how-to-registrasi-diskusiweb-com-baca-ini-terlebih-dahulu
- Cara menyisipkan kode program supaya tampil rapi dan terformat dengan baik di diskusiweb.com: http://www.diskusiweb.com/discussion/50415/cara-menyisipkan-kode-program-di-diskusiweb-com
- Cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

Membaca XML ke PHP

Bagaimana jika membaca XML jika bertingkat seperti ini ?<div class='geshi_syntax'><table><tr><td><div class='code'><pre class="xml"> 
 
<span class="sc3"><span class="re1"><ALAWAR_EXPORT<span class="re2">></span></span></span>
<span class="sc3"><span class="re1"><Options</span><span class="re2">/></span></span>
 
<span class="sc3"><span class="re1"><Languages<span class="re2">></span></span></span>
 
<span class="sc3"><span class="re1"><Language</span> <span class="re0">Code</span>=<span class="st0">"id"</span><span class="re2">></span></span>
 
<span class="sc3"><span class="re1"><CatalogTypes<span class="re2">></span></span></span>
<span class="sc3"><span class="re1"><CatalogType</span> <span class="re0">Code</span>=<span class="st0">"casualpcgames"</span> <span class="re0">Name</span>=<span class="st0">"PC Games"</span><span class="re2">/></span></span>
<span class="sc3"><span class="re1"><CatalogType</span> <span class="re0">Code</span>=<span class="st0">"onlinegames"</span> <span class="re0">Name</span>=<span class="st0">"Online games"</span><span class="re2">/></span></span>
<span class="sc3"><span class="re1"></CatalogTypes<span class="re2">></span></span></span>
 
<span class="sc3"><span class="re1"><Catalogs<span class="re2">></span></span></span>
 
<span class="sc3"><span class="re1"><Catalog</span> <span class="re0">Code</span>=<span class="st0">"casualpcgames"</span><span class="re2">></span></span>
 
<span class="sc3"><span class="re1"><CatalogInfo<span class="re2">></span></span></span>
<span class="sc3"><span class="re1"><Name<span class="re2">></span></span></span>PC Games<span class="sc3"><span class="re1"></Name<span class="re2">></span></span></span>
<span class="sc3"><span class="re1"><PartnerID<span class="re2">></span></span></span>12100<span class="sc3"><span class="re1"></PartnerID<span class="re2">></span></span></span>
<span class="sc3"><span class="re1"></CatalogInfo<span class="re2">></span></span></span>
 
<span class="sc3"><span class="re1"><Dictionaries<span class="re2">></span></span></span>
 
<span class="sc3"><span class="re1"><Dictionary</span> <span class="re0">Code</span>=<span class="st0">"all-games"</span> <span class="re0">Name</span>=<span class="st0">"All Games"</span><span class="re2">></span></span>
 
<span class="sc3"><span class="re1"><DictionaryItem</span> <span class="re0">Code</span>=<span class="st0">"all-games"</span><span class="re2">></span></span>
<span class="sc3"><span class="re1"><Name<span class="re2">></span></span></span>All Games<span class="sc3"><span class="re1"></Name<span class="re2">></span></span></span>
 
<span class="sc3"><span class="re1"><Elements<span class="re2">></span></span></span>
<span class="sc3"><span class="re1"><Element</span> <span class="re0">ID</span>=<span class="st0">"2160"</span><span class="re2">/></span></span>
<span class="sc3"><span class="re1"><Element</span> <span class="re0">ID</span>=<span class="st0">"2163"</span><span class="re2">/></span></span>
<span class="sc3"><span class="re1"><Element</span> <span class="re0">ID</span>=<span class="st0">"2164"</span><span class="re2">/></span></span>
<span class="sc3"><span class="re1"><Element</span> <span class="re0">ID</span>=<span class="st0">"2165"</span><span class="re2">/></span></span>
<span class="sc3"><span class="re1"></Elements<span class="re2">></span></span></span>
<span class="sc3"><span class="re1"></DictionaryItem<span class="re2">></span></span></span>
<span class="sc3"><span class="re1"></Dictionary<span class="re2">></span></span></span>
 
<span class="sc3"><span class="re1"><Dictionary</span> <span class="re0">Code</span>=<span class="st0">"Genre"</span> <span class="re0">Name</span>=<span class="st0">"Genres"</span><span class="re2">></span></span>
 
<span class="sc3"><span class="re1"><DictionaryItem</span> <span class="re0">Code</span>=<span class="st0">"mencocokan_3"</span><span class="re2">></span></span>
<span class="sc3"><span class="re1"><Name<span class="re2">></span></span></span>Mencocokan 3<span class="sc3"><span class="re1"></Name<span class="re2">></span></span></span>
 
<span class="sc3"><span class="re1"><Elements<span class="re2">></span></span></span>
<span class="sc3"><span class="re1"><Element</span> <span class="re0">ID</span>=<span class="st0">"2164"</span> <span class="re0">Value</span>=<span class="st0">"120"</span><span class="re2">/></span></span>
<span class="sc3"><span class="re1"></Elements<span class="re2">></span></span></span>
<span class="sc3"><span class="re1"></DictionaryItem<span class="re2">></span></span></span>
 
<span class="sc3"><span class="re1"><DictionaryItem</span> <span class="re0">Code</span>=<span class="st0">"manajemen_waktu"</span><span class="re2">></span></span>
<span class="sc3"><span class="re1"><Name<span class="re2">></span></span></span>Manajemen Waktu<span class="sc3"><span class="re1"></Name<span class="re2">></span></span></span>
 
<span class="sc3"><span class="re1"><Elements<span class="re2">></span></span></span>
<span class="sc3"><span class="re1"><Element</span> <span class="re0">ID</span>=<span class="st0">"2160"</span> <span class="re0">Value</span>=<span class="st0">"84"</span><span class="re2">/></span></span>
<span class="sc3"><span class="re1"><Element</span> <span class="re0">ID</span>=<span class="st0">"2163"</span> <span class="re0">Value</span>=<span class="st0">"7"</span><span class="re2">/></span></span>
<span class="sc3"><span class="re1"></Elements<span class="re2">></span></span></span>
<span class="sc3"><span class="re1"></DictionaryItem<span class="re2">></span></span></span>
 
<span class="sc3"><span class="re1"><DictionaryItem</span> <span class="re0">Code</span>=<span class="st0">"arcade_and_aksi"</span><span class="re2">></span></span>
<span class="sc3"><span class="re1"><Name<span class="re2">></span></span></span>Arcade <span class="sc1">& Aksi</Name></span>
 
<span class="sc1"><Elements></span>
<span class="sc1"><Element ID="2165" Value="30"/></span>
<span class="sc1"></Elements></span>
<span class="sc1"></DictionaryItem></span>
<span class="sc1"></Dictionary></span>
 
<span class="sc1"><Dictionary Code="Rating" Name="Rating"></span>
 
<span class="sc1"><DictionaryItem Code="rating-hit"></span>
<span class="sc1"><Name>Rating: All popular games</Name></span>
 
<span class="sc1"><Elements></span>
<span class="sc1"><Element ID="2160" Value="84"/></span>
<span class="sc1"><Element ID="2163" Value="7"/></span>
<span class="sc1"><Element ID="2164" Value="120"/></span>
<span class="sc1"><Element ID="2165" Value="30"/></span>
<span class="sc1"></Elements></span>
<span class="sc1"></DictionaryItem></span>
 
<span class="sc1"><DictionaryItem Code="rating-top"></span>
<span class="sc1"><Name>Rating: All hit games</Name></span>
 
<span class="sc1"><Elements></span>
<span class="sc1"><Element ID="2160" Value="294"/></span>
<span class="sc1"><Element ID="2163" Value="120"/></span>
<span class="sc1"><Element ID="2164" Value="290"/></span>
<span class="sc1"><Element ID="2165" Value="120"/></span>
<span class="sc1"></Elements></span>
<span class="sc1"></DictionaryItem></span>
<span class="sc1"></Dictionary></span>
<span class="sc1"></Dictionaries></span>
 
<span class="sc1"><Items></span>
 
<span class="sc1"><Item ID="2160"></span>
<span class="sc1"><Name>Farm Frenzy</Name></span>
 
<span class="sc1"><Properties></span>
<span class="sc1"><Property Code="SymbolCode">farm-frenzy</Property></span>
<span class="sc1"><Property Code="ReleaseDate">2010-12-15 00:00:00</Property></span>
 
<span class="sc1"><Property Code="FullVersionFeatures"></span>
<span class="sc1"><ul><li>Lebih dari 45 level untuk dikalahkan</span>
<span class="sc1"></li></ul></span>
<span class="sc1"></Property></span>
<span class="sc1"><Property Code="SystemRequirements">Windows XP/Vista/7</span>
<span class="sc1">1 GHz</span>
<span class="sc1">256 MB</span>
<span class="sc1">DirectX 8.0</Property></span>
<span class="sc1"><Property Code="Description45" Type="plain">Tunjukan ke si tua MacDonald hasilnya!</Property></span>
 
<span class="sc1"><Property Code="Description80" Type="plain"></span>
<span class="sc1">Permainan arcade menyenangkan untuk menunjukan ke si tua MacDonald hasilnya!</span>
<span class="sc1"></Property></span>
 
<span class="sc1"><Property Code="Description450" Type="plain"></span>
<span class="sc1">Jika kamu berpikir hidup di kota besar adalah gila, tunggu sampai kamu mendapatkan hasil perkebunan di Farm Frenzy, permainan arcade menyenangkan terakhir untuk menunjukan ke si tua MacDonald hasilnya!</span>
<span class="sc1"></Property></span>
 
<span class="sc1"><Property Code="Description2000" Type="html"></span>
<span class="sc1"><p>Jika kamu berpikir hidup di kota besar adalah gila, tunggu sampai kamu mendapatkan hasil perkebunan di <b>Farm Frenzy</b></p></span>
<span class="sc1"></Property></span>
 
<span class="sc1"><Property Code="OrderUrl"></span>
<span class="sc1">http://eu.data.payments.services.alawar.com/order.php?gid=2160&pid=12100&locale=id</span>;
<span class="sc1"></Property></span>
<span class="sc1"><Property Code="Locale">id</Property></span>
<span class="sc1"></Properties></span>
 
<span class="sc1"><Files></span>
 
<span class="sc1"><File Type="distrib" Timestamp="1292311104" Name="FarmFrenzyId_12100.exe" Size="19.74Mb"></span>
<span class="sc1">http://eu.alawar.com/download/FarmFrenzyId_12100.exe</span>;
<span class="sc1"></File></span>
<span class="sc1"></Files></span>
 
<span class="sc1"><Images></span>
 
<span class="sc1"><Image Type="icon44x44" Width="44" Height="44"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/84b/farm-frenzy-icon.gif</span>;
<span class="sc1"></Image></span>
 
<span class="sc1"><Image Type="icon44x44bg" Width="44" Height="44" Timestamp="1290675752"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/3bd/farm-frenzy-iconbg.gif</span>;
<span class="sc1"></Image></span>
 
<span class="sc1"><Image Type="icon100x100" Width="100" Height="100" Timestamp="1290675752"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/3a6/farm-frenzy-pic.gif</span>;
<span class="sc1"></Image></span>
 
<span class="sc1"><Image Type="icon100x100bg" Width="100" Height="100" Timestamp="1290675752"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/ca1/farm-frenzy-picbg.gif</span>;
<span class="sc1"></Image></span>
 
<span class="sc1"><Image Type="logo190x140" Width="190" Height="140"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/410/farm-frenzy-logo.gif</span>;
<span class="sc1"></Image></span>
 
<span class="sc1"><Image Type="banner586x152" Width="586" Height="152" Timestamp="1291627624"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/410/FarmFrenzy_586eng.jpg</span>;
<span class="sc1"></Image></span>
<span class="sc1"></Images></span>
 
<span class="sc1"><Screenshots></span>
 
<span class="sc1"><Screenshot ID="0" Type="small" Width="100" Height="75" Timestamp="1291627623"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/d81/screenshot.01.jpg</span>;
<span class="sc1"></Screenshot></span>
 
<span class="sc1"><Screenshot ID="0" Type="big" Width="640" Height="480" Timestamp="1291627622"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/0d0/screenshot.01.jpg</span>;
<span class="sc1"></Screenshot></span>
 
<span class="sc1"><Screenshot ID="1" Type="small" Width="100" Height="75" Timestamp="1291627623"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/876/screenshot.02.jpg</span>;
<span class="sc1"></Screenshot></span>
 
<span class="sc1"><Screenshot ID="1" Type="big" Width="640" Height="480" Timestamp="1291627623"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/dc5/screenshot.02.jpg</span>;
<span class="sc1"></Screenshot></span>
 
<span class="sc1"></Screenshots></span>
<span class="sc1"><RelatedItems/></span>
<span class="sc1"></Item></span>
 
<span class="sc1"><Item ID="2165"></span>
<span class="sc1"><Name>Bola Ajaib 3</Name></span>
 
<span class="sc1"><Properties></span>
<span class="sc1"><Property Code="SymbolCode">smash-frenzy-3</Property></span>
<span class="sc1"><Property Code="ReleaseDate">2010-12-15 00:00:00</Property></span>
 
<span class="sc1"><Property Code="FullVersionFeatures"></span>
<span class="sc1"><ul><li>Tiga modus permainan</span>
<span class="sc1"></li><li>60 level yang menegangkan</span>
<span class="sc1"></li><li>Visual yang halus</span>
<span class="sc1"></li><li>Modus pilihan untuk layar penuh atau tidak</span>
<span class="sc1"></li><li>Efek musik dan suara yang luar biasa</li></ul></span>
<span class="sc1"></Property></span>
 
<span class="sc1"><Property Code="SystemRequirements"></span>
<span class="sc1">OS: Windows XP/Vista</span>
<span class="sc1">CPU: Pentium 4 or equivalent</span>
<span class="sc1">RAM: 256 Mb</span>
<span class="sc1">DirectX 8.0</span>
<span class="sc1"></Property></span>
<span class="sc1"><Property Code="Description45" Type="plain">3D Permainan bola ajaib!</Property></span>
 
<span class="sc1"><Property Code="Description80" Type="plain"></span>
<span class="sc1">Menampilkan permainan yang menakjubkan dan menyenangkan ke dalam satu permainan!</span>
<span class="sc1"></Property></span>
 
<span class="sc1"><Property Code="Description450" Type="plain"></span>
<span class="sc1">Menampilkan permainan yang menakjubkan dan menyenangkan ke dalam satu permainan!</span>
<span class="sc1"></Property></span>
 
<span class="sc1"><Property Code="Description2000" Type="html"></span>
<span class="sc1"><p>Anda pikir Anda akan mengalahkan penyihir jahat untuk selamanya. </p></span>
<span class="sc1"></Property></span>
 
<span class="sc1"><Property Code="OrderUrl"></span>
<span class="sc1">http://eu.data.payments.services.alawar.com/order.php?gid=2165&pid=12100&locale=id</span>;
<span class="sc1"></Property></span>
<span class="sc1"><Property Code="Locale">id</Property></span>
<span class="sc1"></Properties></span>
 
<span class="sc1"><Files></span>
 
<span class="sc1"><File Type="distrib" Timestamp="1292238833" Name="SmashFrenzy3Id_12100.exe" Size="20.14Mb"></span>
<span class="sc1">http://eu.alawar.com/download/SmashFrenzy3Id_12100.exe</span>;
<span class="sc1"></File></span>
<span class="sc1"></Files></span>
 
<span class="sc1"><Images></span>
 
<span class="sc1"><Image Type="icon44x44" Width="44" Height="44" Timestamp="1290685003"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/bd6/smash-frenzy-3-icon.gif</span>;
<span class="sc1"></Image></span>
 
<span class="sc1"><Image Type="icon44x44bg" Width="44" Height="44" Timestamp="1290685003"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/d70/smash-frenzy-3-iconbg.gif</span>;
<span class="sc1"></Image></span>
 
<span class="sc1"><Image Type="icon100x100" Width="100" Height="100" Timestamp="1290685003"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/af5/smash-frenzy-3-pic.gif</span>;
<span class="sc1"></Image></span>
 
<span class="sc1"><Image Type="icon100x100bg" Width="100" Height="100" Timestamp="1290685003"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/617/smash-frenzy-3-picbg.gif</span>;
<span class="sc1"></Image></span>
 
<span class="sc1"></Images></span>
 
<span class="sc1"><Screenshots></span>
 
<span class="sc1"><Screenshot ID="0" Type="small" Width="100" Height="75" Timestamp="1291627319"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/d13/screenshot1.jpg</span>;
<span class="sc1"></Screenshot></span>
 
<span class="sc1"><Screenshot ID="1" Type="small" Width="100" Height="75" Timestamp="1291627319"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/fd2/screenshot2.jpg</span>;
<span class="sc1"></Screenshot></span>
 
<span class="sc1"><Screenshot ID="1" Type="big" Width="640" Height="480" Timestamp="1291627319"></span>
<span class="sc1">http://eu.alawar.com/upload/iblock/4ab/screenshot2.jpg</span>;
<span class="sc1"></Screenshot></span>
 
<span class="sc1"></Screenshots></span>
<span class="sc1"><RelatedItems/></span>
<span class="sc1"></Item></span>
<span class="sc1"></Items></span>
<span class="sc1"></Catalog></span>
 
<span class="sc1"><Catalog Code="onlinegames"></span>
 
<span class="sc1"><CatalogInfo></span>
<span class="sc1"><Name/></span>
<span class="sc1"><PartnerID>12100</PartnerID></span>
<span class="sc1"></CatalogInfo></span>
 
<span class="sc1"><Dictionaries></span>
<span class="sc1"><Dictionary Code="all-games" Name=""></span>
<span class="sc1"><DictionaryItem Code="all-games"></span>
<span class="sc1"><Name/></span>
<span class="sc1"><Elements> </Elements></span>
<span class="sc1"></DictionaryItem></span>
<span class="sc1"></Dictionary></span>
<span class="sc1"><Dictionary Code="Rating" Name="Rating"></span>
<span class="sc1"><DictionaryItem Code="rating-hit"></span>
<span class="sc1"><Name>Rating: All hit games</Name></span>
<span class="sc1"><Elements></span>
<span class="sc1"> </Elements></span>
<span class="sc1"></DictionaryItem></span>
<span class="sc1"></Dictionary></span>
<span class="sc1"></Dictionaries></span>
<span class="sc1"><Items></span>
 
 
 
<span class="sc1"> </Items></span>
<span class="sc1"></Catalog></span>
<span class="sc1"></Catalogs></span>
<span class="sc1"></Language></span>
<span class="sc1"></Languages></span>
<span class="sc1"></ALAWAR_EXPORT></span></pre></div></td></tr></table></div>
Tagged:

Comments

  • edited March 2011
    Ternyata saya sudah menemukan solusinya

    <pre lang="php" width="500">


    <?php

    // membuka dan membaca file XML

    $xml = simplexml_load_file('file.xml') or die ("Tidak bisa membuka atau membaca XML!");

    foreach($xml->Languages as $Lang)
    {
    foreach($Lang->Language as $Language){
    if($Language["Code"]=="id"){
    foreach($Language->Catalogs->Catalog as $Catalog){
    if($Catalog["Code"]=="casualpcgames"){
    foreach($Catalog->Dictionaries->Dictionary as $Dictionary){
    echo $Dictionary["Code"]."<br>";
    if($Dictionary["Code"]=="all-games"){
    foreach($Dictionary->DictionaryItem->Elements->Element as $Element){
    echo $Element["ID"]."<br>";
    }
    }elseif($Dictionary["Code"]=="Genre"){
    foreach($Dictionary->DictionaryItem as $DictionaryItem){
    echo $DictionaryItem->Name."<br>";
    foreach($DictionaryItem->Elements->Element as $Element){
    echo $Element["ID"]."<br>";
    }
    }
    }elseif($Dictionary["Code"]=="Rating"){
    foreach($Dictionary->DictionaryItem as $DictionaryItem){
    echo $DictionaryItem->Name."<br>";
    foreach($DictionaryItem->Elements->Element as $Element){
    echo $Element["ID"]." => ".$Element["Value"]."<br>";
    }
    }
    }
    echo "<hr>";
    }
    echo "<h2>DETAIL ITEM</h2>";
    foreach($Catalog->Items->Item as $Item){
    echo "<h3>".$Item["ID"]."</h3>";
    echo $Item->Name."<br>";
    foreach($Item->Properties->Property as $Property){
    echo $Property["Code"]." => ".$Property."<br>";
    }
    foreach($Item->Files->File as $File){
    echo "File => ".$File."<br>";
    }
    foreach($Item->Images->Image as $Image){
    echo "Image ".$Image["Type"]." => ".$Image."<br>";
    }
    foreach($Item->Screenshots->Screenshot as $Screenshot){
    echo "Screenshots ".$Screenshot["ID"]." ".$Screenshot["Type"]." => ".$Screenshot."<br>";
    }
    }
    }
    }
    }
    }
    }


    ?>


    </pre>
Sign In or Register to comment.