<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>xml sitemaps | Nerdpress.org</title>
	<atom:link href="https://nerdpress.org/tag/xml-sitemaps/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerdpress.org</link>
	<description>...dev, tech problems and solutions.</description>
	<lastBuildDate>Sun, 03 Feb 2013 10:06:41 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Create Google XML (Image) Sitemaps in PHP</title>
		<link>https://nerdpress.org/2012/10/20/create-google-xml-image-sitemaps-in-php/</link>
					<comments>https://nerdpress.org/2012/10/20/create-google-xml-image-sitemaps-in-php/#comments</comments>
		
		<dc:creator><![CDATA[Max Girkens]]></dc:creator>
		<pubDate>Sat, 20 Oct 2012 17:09:06 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[xml sitemaps]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2260</guid>

					<description><![CDATA[<p>Ever wanted to create a Google XML Image Sitemap? This is how it could be done with PHP: That&#8217;s about it. I found it kind of tricky to figure out how to use googles namespaces when working with SimpleXML, so hopefully this might help someone :)</p>
The post <a href="https://nerdpress.org/2012/10/20/create-google-xml-image-sitemaps-in-php/">Create Google XML (Image) Sitemaps in PHP</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>Ever wanted to create a Google XML <a title="Image Sitemaps" href="http://support.google.com/webmasters/bin/answer.py?hl=en&amp;answer=178636">Image Sitemap</a>?</p>
<p>This is how it could be done with PHP:<span id="more-2260"></span><br /><script src="https://gist.github.com/3924036.js"></script><noscript><pre><code class="language-php php">header(&quot;Content-type: text/xml; charset=utf-8&quot;);

//create your XML document, using the namespaces
$urlset = new SimpleXMLElement(&#039;&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;urlset xmlns=&quot;http://www.sitemaps.org/schemas/sitemap/0.9&quot; xmlns:image=&quot;http://www.google.com/schemas/sitemap-image/1.1&quot; /&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;&#039;);

//iterate over your sites pages or whatever you like

foreach (getMyPagesOrWhatEver() as $item):

    //add the page URL to the XML urlset
    $url = $urlset-&gt;addChild(&#039;url&#039;);
    $url-&gt;addChild(&#039;loc&#039;, $item-&gt;URL&nbsp;);
    $url-&gt;addChild(&#039;lastmod&#039;, $item-&gt;LASTMOD );
    $url-&gt;addChild(&#039;changefreq&#039;, &#039;daily&#039;); &nbsp;//weekly etc.
    $url-&gt;addChild(&#039;priority&#039;, &#039;1.0&#039;);

    //add an image
    if ( $item-&gt;IMAGE ):
        $image = $url-&gt;addChild(&#039;image:image&#039;, null, &#039;http://www.google.com/schemas/sitemap-image/1.1&#039;);
        $image-&gt;addChild(&#039;image:loc&#039;,$item-&gt;IMAGE-&gt;URL, &#039;http://www.google.com/schemas/sitemap-image/1.1&#039;);
        $image-&gt;addChild(&#039;image:caption&#039;,$item-&gt;IMAGE-&gt;ALT_OR_TITLE&nbsp;, &#039;http://www.google.com/schemas/sitemap-image/1.1&#039;);
    endif;

endforeach;

//add whitespaces to xml output (optional, of course)
$dom = new DomDocument();
$dom-&gt;loadXML($urlset-&gt;asXML());
$dom-&gt;formatOutput = true;
//output xml

echo $dom-&gt;saveXML();</code></pre></noscript></p>
<p>That&#8217;s about it.</p>
<p>I found it kind of tricky to figure out how to use googles namespaces when working with SimpleXML, so hopefully this might help someone :)</p>The post <a href="https://nerdpress.org/2012/10/20/create-google-xml-image-sitemaps-in-php/">Create Google XML (Image) Sitemaps in PHP</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
					<wfw:commentRss>https://nerdpress.org/2012/10/20/create-google-xml-image-sitemaps-in-php/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
