• 28-08-2019, 15:58:58
    #1
    Merhabalar,
    Elimizde aşağıdaki gibi bir XML var fakat attribute olarak geldiği için veriyi alamıyoruz yardımcı olabilir misiniz?

    <Stok ....... /> : bir adet ürüne tekabül etmektedir.
  • 28-08-2019, 16:11:40
    #2
    $dosyayicek = file_get_contents("https://site.com/d.xml");
    $decodeislemi = json_decode($dosyayicek);
    $hata=$decodeislemi->ErrorCode;
    if ($hata<>"0"){
        echo "sistem hatası";
    }
    
    
    
    foreach (($decodeislemi->Value) as $y)
    {
    
    
    $i = json_decode(json_encode($y), True);
    
    
    echo $i['AnaGrupKod'];
    
    }
  • 28-08-2019, 16:16:06
    #3
    gencbeyin adlı üyeden alıntı: mesajı görüntüle
    $dosyayicek = file_get_contents("https://site.com/d.xml");
    $decodeislemi = json_decode($dosyayicek);
    $hata=$decodeislemi->ErrorCode;
    if ($hata<>"0"){
        echo "sistem hatası";
    }
    
    
    
    foreach (($decodeislemi->Value) as $y)
    {
    
    
    $i = json_decode(json_encode($y), True);
    
    
    echo $i['AnaGrupKod'];
    
    }
    Hocam kodu deniyorum fakat sistem hatası verdi?
  • 28-08-2019, 16:16:36
    #4
    $xml = simplexml_load_string($string);
    foreach($xml->foo[0]->attributes() as $a => $b) {
    echo $a,'="',$b,""n";
    }
  • 28-08-2019, 16:16:52
    #5
    Misafir adlı üyeden alıntı: mesajı görüntüle
    $xml = simplexml_load_string($string);
    foreach($xml->foo[0]->attributes() as $a => $b) {
    echo $a,'="',$b,""n";
    }
    denedik bununla alamıyoruz.
  • 28-08-2019, 16:17:29
    #6
    gencbeyin adlı üyeden alıntı: mesajı görüntüle
    $dosyayicek = file_get_contents("https://site.com/d.xml");
    $decodeislemi = json_decode($dosyayicek);
    $hata=$decodeislemi->ErrorCode;
    if ($hata<>"0"){
        echo "sistem hatası";
    }
    
    
    
    foreach (($decodeislemi->Value) as $y)
    {
    
    
    $i = json_decode(json_encode($y), True);
    
    
    echo $i['AnaGrupKod'];
    
    }
    soruyu json olarak sormamış xml olarak sormuş.
  • 28-08-2019, 16:18:33
    #7
    emreakdascomtr adlı üyeden alıntı: mesajı görüntüle
    Hocam kodu deniyorum fakat sistem hatası verdi?
    json decode olmuyor, ise
    echo "sistem hatası";
    kısmını
    echo "sistem hatası".$hata;
    olarak değiştirin neden decode edemediğine bakalım.
  • 28-08-2019, 16:19:47
    #8
    Misafir adlı üyeden alıntı: mesajı görüntüle
    soruyu json olarak sormamış xml olarak sormuş.
    arkadaş xml'i jsona döküyor jsondan çeksekte problem olmaz.
  • 28-08-2019, 16:20:48
    #9
    Misafir adlı üyeden alıntı: mesajı görüntüle
    soruyu json olarak sormamış xml olarak sormuş.
    evet doğru ben niye json algıladım bilmiyorum. pardon.