<?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>Devdevote&#187; PHP &amp; SQL</title>
	<atom:link href="http://www.devdevote.com/server-script/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devdevote.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 06 Mar 2011 13:06:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Use Xpath to parse HTML content with PHP</title>
		<link>http://www.devdevote.com/server-script/php/use-xpath-to-parse-html-content-with-php</link>
		<comments>http://www.devdevote.com/server-script/php/use-xpath-to-parse-html-content-with-php#comments</comments>
		<pubDate>Mon, 27 Sep 2010 17:36:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=197</guid>
		<description><![CDATA[Information will be added soon.]]></description>
			<content:encoded><![CDATA[<p>Information will be added soon.</p>
<pre class="brush: php; title: ; notranslate">
$content = '&lt;div class=&quot;test&quot;&gt;&lt;a href=&quot;test.se&quot;&gt;Link&lt;/a&gt;&lt;/div&gt;';
$dom = new DOMDocument();
$dom-&gt;loadHTML($content);
$xpath = new DomXPath($dom);
$tag = $dom-&gt;getElementsByTagName(&quot;a&quot;);
$counter = $tag-&gt;length;
for ($i = 0; $i &lt; $counter; $i++) {
	$result = $tag-&gt;item($i)-&gt;nodeValue;
	$content = str_replace($result, '&lt;img src=&quot;http://www.google.com/s2/favicons?domain=seo.getupdated.se&amp;alt=feed&quot; /&gt;'.$result, $content);
	echo $tag-&gt;item($i)-&gt; getAttribute('href').'&lt;br&gt;';
}
</pre>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.devdevote.com%2Fserver-script%2Fphp%2Fuse-xpath-to-parse-html-content-with-php&amp;title=Use%20Xpath%20to%20parse%20HTML%20content%20with%20PHP" id="wpa2a_2"><img src="http://www.devdevote.com/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/server-script/php/use-xpath-to-parse-html-content-with-php/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP Resources</title>
		<link>http://www.devdevote.com/server-script/php-sql-resources/php-resources</link>
		<comments>http://www.devdevote.com/server-script/php-sql-resources/php-resources#comments</comments>
		<pubDate>Mon, 19 Jul 2010 20:13:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Resources]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=184</guid>
		<description><![CDATA[A list with PHP functions to save time or save the day.]]></description>
			<content:encoded><![CDATA[<p>A list with PHP functions to save time or save the day.</p>
<h2>Helpful PHP functions</h2>
<ul>
<li><a href="http://www.catswhocode.com/blog/10-life-saving-php-snippets">Cats who code &#8211; PHP snippets</a></li>
<li><a href="http://www.catswhocode.com/blog/10-php-code-snippets-for-working-with-strings">Cats who code &#8211; PHP string functions</a></li>
<li><a href="http://edrackham.com/php/get-days-between-two-dates-using-php/">Edrackham &#8211; Get days between two dates</a></li>
<li><a href="http://www.24hourapps.com/2009/03/php-dates-between-two-dates-tutorial.html">24 hour apps &#8211; Dates between two dates</a></li>
</ul>
<h2>Misc</h2>
<ul>
<li><a href="http://www.kavoir.com/2009/01/php4-class-differences-from-php5.html">Kavoir &#8211; Make PHP5 classes work with PHP4</a></li>
<li><a href="http://css-tricks.com/css-variables-with-php/">CSS tricks &#8211; CSS with PHP</a></li>
<li><a href="http://www.electrictoolbox.com/php-str-replace-associative-array/">Electric tool box &#8211; Associative array with str_replace</a></li>
<li><a href="http://scripts.franciscocharrua.com/php-calendar.php">My little scripts &#8211; PHP calendar</a></li>
</ul>
<p>Leave a comment if you know a great resource to PHP functions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/server-script/php-sql-resources/php-resources/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Create URL friendly strings like WordPress</title>
		<link>http://www.devdevote.com/server-script/php/create-url-friendly-strings-like-wordpress</link>
		<comments>http://www.devdevote.com/server-script/php/create-url-friendly-strings-like-wordpress#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:59:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=55</guid>
		<description><![CDATA[Wordpress rewrite their URLs in a beautiful way which makes them very user friendly. I've created a function that converts a string to be user friendly, the Wordpress way.]]></description>
			<content:encoded><![CDATA[<p class="red">WordPress rewrite their URLs in a beautiful way which makes them very user friendly. I&#8217;ve created a function that converts a string to be user friendly, the WordPress way.</p>
<h3 class="red">Don&#8217;t use urlencode</h3>
<p>In PHP there is a function to convert strings to be URL friendly. The function is called <a title="urlencode" href="http://se.php.net/urlencode">urlencode</a>.</p>
<h3>Function call &#8211; urlencode</h3>
<pre>$string = 'Det här är ett "citat" i en url';
echo urlencode($string);</pre>
<h3>Printed out on the screen</h3>
<pre>Det+h%E4r+%E4r+ett+%22citat%22+i+en+url</pre>
<p>Unfortunately, it doesn&#8217;t look very good.</p>
<h3 class="green">Use super_urlencode instead</h3>
<p>The advantage of super_urlencode is that the string looks much better for humans. This version of super_urlencode  is made for swedish characters but works fine with english URLs as well.</p>
<h3>Function &#8211; super_urlencode</h3>
<pre>&lt;?php
$string = 'Det här är ett "citat" i en url';

function super_urlencode($string)
{
     $string = trim($string);
     $string = strtolower($string);
     $string = str_replace(array('å', 'ä', 'ö', ' '), array('a', 'a', 'o', '-'), $string);
     $string = preg_replace("/[^a-z0-9-]/", "", $string);
     $string = preg_replace("/[-]+/", "-", $string);

     return $string;
}
echo super_urlencode($string);
?&gt;</pre>
<h3>Function call &#8211; super_urlencode</h3>
<pre>$string= 'Det här är ett "citat" i en url';
echo super_urlencode($string);</pre>
<h3>Printed out on the screen</h3>
<pre>det-har-ar-ett-citat-i-en-url</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/server-script/php/create-url-friendly-strings-like-wordpress/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get XML data with Xpath &amp; Curl</title>
		<link>http://www.devdevote.com/server-script/php/get-xml-data-with-xpath-curl</link>
		<comments>http://www.devdevote.com/server-script/php/get-xml-data-with-xpath-curl#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:58:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.devdevote.com/?p=53</guid>
		<description><![CDATA[This example is downloading data from an XML file from an RSS feed by using XPath. The XML file is downloaded with Curl, so make sure it is enabled on the server that runs the script. The titles are printed out, just to show that it works.]]></description>
			<content:encoded><![CDATA[<p>There are several ways to get and manage XML data from an RSS feed in PHP. XPath is recommended for this type of problem. All servers do not support simplexml_load_file, but it is possible to get XML data with Curl instead, which will be much safer.</p>
<h2>Example</h2>
<p>This example is downloading data from an XML file from an RSS feed by using XPath. The XML file is downloaded with Curl, so make sure it is enabled on the server that runs the script. The titles are printed out, just to show that it works. Copy, paste and run the code on a server and it should work instantly. The RSS feed I choose for this example is WordPress development blog.</p>
<pre>&lt;?php
function get_url($url)
{
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_HEADER, 0);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_URL, $url);
     $data = curl_exec($curl);
     curl_close($curl);
     return $data;
}

function get_url_data()
{
     $xml_content = get_url("http://wordpress.org/development/feed/");
     $dom = new DOMDocument();
     @$dom-&gt;loadXML($xml_content);
     $xpath = new DomXPath($dom);
     $content_title = $xpath-&gt;query('<strong>//channel//title/text()</strong>');
     return $content_title;
}

function print_url_data()
{
     $content = get_url_data();
     foreach ($content as $value)
     {
          $output .= $value-&gt;nodeValue . "&lt;br /&gt;";
     }
     return $output;
}

echo print_url_data();
?&gt;</pre>
<h3>Change Xpath to get the title, description and link</h3>
<p>The example above prints out the titles. You might need to print out URL or descriptions as well. Change the bold part with the Xpath query of your choice:</p>
<pre>//channel//title/text()
//channel//description/text()
//channel//link/text()</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.devdevote.com/server-script/php/get-xml-data-with-xpath-curl/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

