• 21-03-2021, 19:46:53
    #1
    merhaba php bir web sitesi xml çıktı almam gerek sorunum ise şudur
    sitede ürün açıklaması html taglar var fakat xml çıktıda düz metin olarak geliyo.
    lütfen yardım rica ediyorum.

    xml çıktı için kod aşağıdaki gibidir

    -------------------------

    ürün açıklamasının bu xml çıktıda bu şekilde gelmesini istiyorum

    <urun_aciklama>
    <![CDATA[ <p>Ürün Özellikleri:</p> <p>* Kapasite: 10 bardak<br /> * Güç: 900 W * Damlatma önleyici sistem<br /> * Cam karaf<br /> * ECO: 40 dk sonra otomatik olarak kapanarak enerji tasarrufu sağlar * Kullanıcı dostu kontrol paneli<br /> * Kahveyi sıcak tutan ısıtıcı taban<br /> * Bulaşık makinesinde yıkanabilir karaf ve filtre sepeti<br /> * Kaymaz taban * Kablo saklama haznesi<br /> Genel Özellikler:<br /> Boyutlar (exbxy): 20.5 x 22.5 x 32.0 cm<br /> Ağırlık (Kg): 1.7<br /> Voltaj/Frekans (V~Hz): 220/240-50/60<br /> Giriş gücü (W): 900<br /> Favori renginizi seçin:<br /> Siyah Fincan sayısı: 10<br /> Otomatik kapanma: Var<br /> Cam sürahi: Var<br /> Sıcak tutma tepsisi: Var<br /> Su filtresi: Var Su seviye göstergesi: Var</p> ]]>
    </urun_aciklama>

    --------------------------------------


    <?php

    class jetxmlController extends Controllers {

    public function init() {

    $this->render = false;

    ob_start();

    echo '<?xml version="1.0" encoding="UTF-8"?>

    <Urunler>';

    $items = array();

    $products = $this->db->toarray("SELECT * FROM products WHERE active = 1 AND price > 0 AND photos != '' GROUP BY sku LIMIT 10");

    $products = setSmartImages($products);

    $descs = $this->db->toarray("SELECT * FROM seo_descriptions WHERE 1");

    foreach($products AS $product) {

    $title = str_replace("!", "", $product['name']);

    $description = str_replace("!", "", html_entity_decode(setSeoDescription($product,$thi s->categories[$product['category']]['name'], ($product['sizes'] ? explode(",", $product['sizes']) : array()), ($product['colors'] ? explode(",", $product['colors']) : array()), $this->brands[$product['brand']]['name'], $this->product['price'], false, $descs)));

    $price = str_replace(".", ",", price_format($product['price']))." TL";
    $sale_price = str_replace(".", ",", price_format($product['price']))." TL";
    $images = array(); foreach($product['photos'] AS $key => $photo)$images[] = CDN_URL."/image/".$photo['smart'];
    $brand = $this->brands[$product['brand']]['name'];
    $category = $this->getProductType($product);

    echo ' <Urun>
    <UrunKodu>'.$product['sku'].'</UrunKodu>
    <Barkod>'.$product['barcode'].'</Barkod>
    <Baslik>'.$title.'</Baslik>
    <Marka>'.$brand.'</Marka>
    <Kategori>'.$category.'</Kategori>
    <SatisFiyat>'.$price.'</SatisFiyat>
    <AlisFiyat>'.$cost_price.'</AlisFiyat>
    <ParaBirimi>TL</ParaBirimi>
    <StokAdet>'.$product['stok'].'</StokAdet>
    <OnDetay>'.$meta_title.'</OnDetay>
    <Aciklama><![CDATA['.$description.']]></Aciklama>
    <Beden isim="Beden">'.$product['sizes'].'</Beden>
    <Renk isim="Renk">'.$product['colors'].'</Renk>
    <SatisAP>'.$product['sold_out'].'</SatisAP>
    <Resimler>';
    foreach($images AS $image) {
    echo '<Resim>'.$image.'</Resim>';
    }
    echo '
    </Resimler>
    </Urun>';
    }

    echo '</Urunler>';

    $content = ob_get_contents();

    ob_end_clean();

    $content = str_replace("{site_domain}", SITE_DOMAIN, str_replace("{site_name}", SITE_NAME, str_replace("{site_mail}", SITE_MAIL, str_replace("{site_order_mail}", SITE_ORDER_MAIL, str_replace("{site_phone}", SITE_PHONE, str_replace("{site_gsm}", SITE_GSM, $content))))));

    $content = str_replace(array('ı','ğ','ü','ş','ö','ç','İ','Ğ', 'Ü','Ş','Ö','Ç'), array('{-xix-}','{-xgx-}','{-xux-}','{-xsx-}','{-xox-}','{-xcx-}','{-xIx-}','{-xGx-}','{-xUx-}','{-xSx-}','{-xOx-}','{-xCx-}'), $content);

    $content = preg_replace('/[[:^print:]]/', '', $content);

    $content = str_replace(array('{-xix-}','{-xgx-}','{-xux-}','{-xsx-}','{-xox-}','{-xcx-}','{-xIx-}','{-xGx-}','{-xUx-}','{-xSx-}','{-xOx-}','{-xCx-}'), array('ı','ğ','ü','ş','ö','ç','İ','Ğ','Ü','Ş','Ö', 'Ç'), $content);

    header("Content-Type: text/xml; charset=utf-8");
    header("Content-Length: ".strlen($content));
    echo $content;

    exit;

    }

    private function getProductType($product) {

    $category = $this->categories[$product['category']];

    $types = array();

    $bc = $category;
    $types[] = $bc['name'];

    if($bc['main'] && $this->categories[$bc['main']]) {

    $bc = $this->categories[$bc['main']];
    $types[] = $bc['name'];

    if($bc['main'] && $this->categories[$bc['main']]) {

    $bc = $this->categories[$bc['main']];
    $types[] = $bc['name'];

    if($bc['main'] && $this->categories[$bc['main']]) {

    $bc = $this->categories[$bc['main']];
    $types[] = $bc['name'];

    }
    }
    }
    return implode(" > ", array_reverse($types));
    }
    }
  • 21-03-2021, 19:52:03
    #2
    https://stackoverflow.com/questions/...n-xml-document

    Şu konu belki işinize yarayabilir.
  • 21-03-2021, 20:37:38
    #3
    maalesef denedim yine beceremedim

    ribrahimozer adlı üyeden alıntı: mesajı görüntüle
    https://stackoverflow.com/questions/...n-xml-document

    Şu konu belki işinize yarayabilir.