• 08-10-2019, 18:15:29
    #1
    Merhabalar, php ile xml datası oluşturdum ama bunu nasıl döngüye sokacağım anlayamadım Veri tabanından gelen bilgilerle "urun" etiketi ve içindeki verileri çoğaltmak istiyorum.

    <?php
    header("Content-Type: application/xml;");
    $xml = new DOMDocument('1.0', 'UTF-8');
    $urunler = $xml->createElement('urunler');
    $urun = $xml->createElement('urun');
    
    $urun->appendChild($xml->createElement('marka', 1));
    $urun->appendChild($xml->createElement('marka_koleksiyon', '-----'));
    $urun->appendChild($xml->createElement('mal_grubu', '-----'));
    $urun->appendChild($xml->createElement('urun_cesidi', '-----'));
    $urun->appendChild($xml->createElement('kdv', '-----'));
    $urun->appendChild($xml->createElement('urun_adi', '-----'));
    $urun->appendChild($xml->createElement('etiket_fiyati', '-----'));
    $urun->appendChild($xml->createElement('site_indirimli_fiyati', '-----'));
    $urun->appendChild($xml->createElement('morhipo_yeni_alis', '-----'));
    $urun->appendChild($xml->createElement('kdv_haric_morhipo_yeni_alis', '-----'));
    $urun->appendChild($xml->createElement('ilkyil', '-----'));
    $urun->appendChild($xml->createElement('yil', '-----'));
    $urun->appendChild($xml->createElement('ilksezon', '-----'));
    $urun->appendChild($xml->createElement('sezon', '-----'));
    $urun->appendChild($xml->createElement('cinsiyet', '-----'));
    $urun->appendChild($xml->createElement('renk', '-----'));
    $urun->appendChild($xml->createElement('beden', '-----'));
    $urun->appendChild($xml->createElement('firma_ana_urun_kodu', '-----'));
    $urun->appendChild($xml->createElement('aciklama', '-----'));
    $urun->appendChild($xml->createElement('stok_adedi', '-----'));
    $urun->appendChild($xml->createElement('barkod', '-----'));
    $urun->appendChild($xml->createElement('resimler', '-----'));
    
    $urunler->appendChild($urun);
    $xml->appendChild($urunler);
    $xml->save('kisiler.xml');
    echo $xml->saveHTML();
    ?>
    Bu bana verdiği çıktı, Ürünleri çoğaltmak istiyorum.


    <urunler>
    <urun>
    <marka>1</marka>
    <marka_koleksiyon>-----</marka_koleksiyon>
    <mal_grubu>-----</mal_grubu>
    <urun_cesidi>-----</urun_cesidi>
    <kdv>-----</kdv>
    <urun_adi>-----</urun_adi>
    <etiket_fiyati>-----</etiket_fiyati>
    <site_indirimli_fiyati>-----</site_indirimli_fiyati>
    <morhipo_yeni_alis>-----</morhipo_yeni_alis>
    <kdv_haric_morhipo_yeni_alis>-----</kdv_haric_morhipo_yeni_alis>
    <ilkyil>-----</ilkyil>
    <yil>-----</yil>
    <ilksezon>-----</ilksezon>
    <sezon>-----</sezon>
    <cinsiyet>-----</cinsiyet>
    <renk>-----</renk>
    <beden>-----</beden>
    <firma_ana_urun_kodu>-----</firma_ana_urun_kodu>
    <aciklama>-----</aciklama>
    <stok_adedi>-----</stok_adedi>
    <barkod>-----</barkod>
    <resimler>-----</resimler>
    
    </urun>
    
    
    
    </urunler>
  • 08-10-2019, 18:18:06
    #2
    while'a dök reis
  • 08-10-2019, 18:19:49
    #3
    emreakdascomtr adlı üyeden alıntı: mesajı görüntüle
    while'a dök reis

    Nereden alıp while döngüsüne sokacağım anlamadım. Onu çözemedim kafam durdu
  • 08-10-2019, 18:21:01
    #4
    ver anydesk özelden geleyim
  • 08-10-2019, 18:21:50
    #5
    Valla deneye deneye buldum sonunda

    bu kısımı döngüye alınca istediğim gibi oldu, teşekkür ederim.

    $urun = $xml->createElement('urun');
    $urun->appendChild($xml->createElement('marka', 1));
    $urun->appendChild($xml->createElement('marka_koleksiyon', '-----'));
    $urun->appendChild($xml->createElement('mal_grubu', '-----'));
    $urun->appendChild($xml->createElement('urun_cesidi', '-----'));
    $urun->appendChild($xml->createElement('kdv', '-----'));
    $urun->appendChild($xml->createElement('urun_adi', '-----'));
    $urun->appendChild($xml->createElement('etiket_fiyati', '-----'));
    $urun->appendChild($xml->createElement('site_indirimli_fiyati', '-----'));
    $urun->appendChild($xml->createElement('morhipo_yeni_alis', '-----'));
    $urun->appendChild($xml->createElement('kdv_haric_morhipo_yeni_alis', '-----'));
    $urun->appendChild($xml->createElement('ilkyil', '-----'));
    $urun->appendChild($xml->createElement('yil', '-----'));
    $urun->appendChild($xml->createElement('ilksezon', '-----'));
    $urun->appendChild($xml->createElement('sezon', '-----'));
    $urun->appendChild($xml->createElement('cinsiyet', '-----'));
    $urun->appendChild($xml->createElement('renk', '-----'));
    $urun->appendChild($xml->createElement('beden', '-----'));
    $urun->appendChild($xml->createElement('firma_ana_urun_kodu', '-----'));
    $urun->appendChild($xml->createElement('aciklama', '-----'));
    $urun->appendChild($xml->createElement('stok_adedi', '-----'));
    $urun->appendChild($xml->createElement('barkod', '-----'));
    $urun->appendChild($xml->createElement('resimler', '-----'));
    $urunler->appendChild($urun);