• 09-05-2014, 11:06:13
    #1
    Üyeliği durduruldu
    image:caption
    mage:title
    image:loc ifadelerini çekmek istiyorum
    ancak : olduğundan dolayı tam yapamadım nasıl yapabilirim
    benim yazdığım php ise bu şekilde ancak resimler ve diğer açıklamalar gelmedi

    $data = simplexml_load_file("http://a.siteadi.com/mp/sitemap.xml");
    foreach ($data->url as $bilgi)
    {
    $adbilgi =$bilgi->loc;
    echo "
    $adbilgi<br>
    ";
    }
    ************************************************** **
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
    <url>
    <loc>http://s.site_adi.com/veriler</loc>
    <priority>0.4</priority>
    <changefreq>daily</changefreq>
    <image:image>
    <image:loc>
    http://www.site_adi.com/yuklemeler/kucuk/s_veriler.jpg
    </image:loc>
    <image:caption>veriler</image:caption>
    <image:title>s veriler</image:title>
    </image:image>
    <image:image>
    <image:loc>
    http://www.site_adi.com/yuklemeler/o.../s_veriler.jpg
    </image:loc>
    <image:caption>veriler</image:caption>
    <image:title>s veriler</image:title>
    </image:image>
    </url>
  • 09-05-2014, 17:53:05
    #2
    Kimlik doğrulama veya yönetimden onay bekliyor.
    @wallstreet; buyrun hocam

    <?php
    
    	$url = "http://abc.def.com/mp/sitemap.xml";
    
    	$response = file_get_contents($url);
    
    	$document = new DOMDocument();
    
    	$document->preserveWhiteSpace = false;
    
    	$document->loadXML($response);
    
    	$data = array('urlset' => array());
    
    	foreach($document->getElementsByTagname('url') as $url)
    	{
    		$index = 0;
    
    		$loc = $url->getElementsByTagName('loc')->item($index)->nodeValue;
    		$priority = $url->getElementsByTagName('priority')->item($index)->nodeValue;
    		$changefreq = $url->getElementsByTagName('changefreq')->item($index)->nodeValue;
    
    		$namespace = 'http://www.google.com/schemas/sitemap-image/1.1';
    
    		$images = array();
    
    		$imageIndexKeys = array_keys(range(1, $url->getElementsByTagNameNS($namespace, 'image')->length));
    
    		foreach($imageIndexKeys as $imageIndex)
    		{
    			$images[] = array(
    				'loc' => $url->getElementsByTagNameNS($namespace, 'loc')->item($imageIndex)->nodeValue,
    				'caption' => $url->getElementsByTagNameNS($namespace, 'caption')->item($imageIndex)->nodeValue,
    				'title' => $url->getElementsByTagNameNS($namespace, 'title')->item($imageIndex)->nodeValue
    			);
    		}
    
    		$data['urlset'][] = array(
    			'loc' => $loc,
    			'priority' => $priority,
    			'changefreq' => $changefreq,
    			'image' => $images
    		);
    	}
    
    	print_r($data['urlset'][0]['image'][0]['caption']); // SND703P
  • 10-05-2014, 01:35:54
    #3
    saintx arkadaşımız gerekli kodu vermiş ama alternatif olarak aşağıdaki gibi bir yöntemde uygulanabilir.

    <?php
    $string = '<?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
    	<url>
    		<loc>http://s.site_adi.com/veriler</loc>
    		<priority>0.4</priority>
    		<changefreq>daily</changefreq>
    		<image:image>
    			<image:loc>http://www.site_adi.com/yuklemeler/kucuk/s_veriler.jpg</image:loc>
    			<image:caption>veriler</image:caption>
    			<image:title>s veriler</image:title>
    		</image:image>
    		<image:image>
    			<image:loc>http://www.site_adi.com/yuklemeler/o.../s_veriler.jpg</image:loc>
    			<image:caption>veriler</image:caption>
    			<image:title>s veriler</image:title>
    		</image:image>
    	</url>
    </urlset>';
    
    $string=preg_replace('/image:(.*?)>/i','$1>',$string);
    
    $data = simplexml_load_string($string);
    print_r($data);
    ?>
  • 10-05-2014, 02:00:01
    #4
        
         header("Content-Type: text/html; charset=utf8");
         foreach (simplexml_load_string($xml) as $img) {
        $loc = $img->loc;
        $cap = $img->image->caption;
        $title = $img->image->title;
    
        }
    Şunuda bir dene hocam olucak gibi duruyor.

    Örnek olması açısından şu koduda gösterim nacizane.

    header("Content-Type: text/html; charset=utf8");
        $dosya = 'http://www.f5haber.com/rss/haberler.xml';
        $a = simplexml_load_file($dosya);
        foreach ($a as $val) {
            foreach ($val->item as $haber) {
    
          
                
                echo $haber->title.'<br>';
                echo $haber->link.'<br>';
                echo $haber->description.'<br>';
                echo $haber->category.'<br>';
                echo $haber->pubDate.'<br>';
                echo $haber->img.'<br>';
                echo '<br>';
            }
            
        }
  • 11-05-2014, 22:47:43
    #5
    Üyeliği durduruldu
    saintx adlı üyeden alıntı: mesajı görüntüle
    @wallstreet; buyrun hocam

    <?php
    
    	$url = "http://abc.def.com/mp/sitemap.xml";
    
    	$response = file_get_contents($url);
    
    	$document = new DOMDocument();
    
    	$document->preserveWhiteSpace = false;
    
    	$document->loadXML($response);
    
    	$data = array('urlset' => array());
    
    	foreach($document->getElementsByTagname('url') as $url)
    	{
    		$index = 0;
    
    		$loc = $url->getElementsByTagName('loc')->item($index)->nodeValue;
    		$priority = $url->getElementsByTagName('priority')->item($index)->nodeValue;
    		$changefreq = $url->getElementsByTagName('changefreq')->item($index)->nodeValue;
    
    		$namespace = 'http://www.google.com/schemas/sitemap-image/1.1';
    
    		$images = array();
    
    		$imageIndexKeys = array_keys(range(1, $url->getElementsByTagNameNS($namespace, 'image')->length));
    
    		foreach($imageIndexKeys as $imageIndex)
    		{
    			$images[] = array(
    				'loc' => $url->getElementsByTagNameNS($namespace, 'loc')->item($imageIndex)->nodeValue,
    				'caption' => $url->getElementsByTagNameNS($namespace, 'caption')->item($imageIndex)->nodeValue,
    				'title' => $url->getElementsByTagNameNS($namespace, 'title')->item($imageIndex)->nodeValue
    			);
    		}
    
    		$data['urlset'][] = array(
    			'loc' => $loc,
    			'priority' => $priority,
    			'changefreq' => $changefreq,
    			'image' => $images
    		);
    	}
    
    	print_r($data['urlset'][0]['image'][0]['caption']); // SND703P
    hocam tek bir sonuç çıktı diğer veriler gelmedi :/
  • 12-05-2014, 21:33:06
    #6
    Gönderdiğin xml dosyasında hata var. < koymayı unutmuşlar sanırım. Ondan hata veriyor. yukarıdaki arkadaşların kodları çalışıyor ama. Yapman gereken dizi halinde gelen sonuçları foreach ile yazdırmak.
  • 13-05-2014, 11:46:23
    #7
    Üyeliği durduruldu
    aLKaDraZ adlı üyeden alıntı: mesajı görüntüle
    Gönderdiğin xml dosyasında hata var. < koymayı unutmuşlar sanırım. Ondan hata veriyor. yukarıdaki arkadaşların kodları çalışıyor ama. Yapman gereken dizi halinde gelen sonuçları foreach ile yazdırmak.
    gelse sorun yok
  • 13-05-2014, 14:57:50
    #8
    header("Content-Type: text/html; charset=utf8");
    $dosya = file_get_contents('sitemap.xml');
    preg_match_all('#<image:image>(.*?)</image:image>#si',$dosya,$dizi);
    echo '<pre>';
    echo var_dump($dizi[1]);
    echo '</pre>';
    Hepsi geliyor gördüğün gibi.