<?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>The Tech Space &#187; xml</title>
	<atom:link href="http://www.thetechspace.com/tag/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thetechspace.com</link>
	<description>php, jquery, flash and resources</description>
	<lastBuildDate>Tue, 08 Nov 2011 08:47:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Output XML using PHP from MySQL database</title>
		<link>http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/</link>
		<comments>http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 05:24:15 +0000</pubDate>
		<dc:creator>Thurein</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.thetechspace.com/?p=279</guid>
		<description><![CDATA[Firstly, Let me talk about this post. If your advance level php programmer, this is a piece of cake for you. I would like to say this post for beginner level. It would be a little difficult for a beginner. You may need xml output when you want to integrate with flash and MySQL records [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Firstly, Let me talk about this post. If your advance level php programmer, this is a piece of cake for you. I would like to say this post for beginner level. It would be a little difficult for a beginner. You may need xml output when you want to integrate with flash and MySQL records such as photo gallery, playlist for flash mp3 player, RSS Feeds, and so on.</p>
<p><span id="more-279"></span>I would like to show you an example to create xml playlist. So you can use this in flash mp3 player like JW Player. I have created songs table in my database. songs_id, album_id, songs_title and songs_link fields are included in this table.</p>
<p>In PHP file :</p>
<pre class="brush:php">
&lt;?php
 header('Content-type: text/xml');
 $db_host = &quot;localhost&quot; ; // MySQL Host
 $db_user = &quot;root&quot; ;    // Database Username
 $db_password = &quot;&quot; ; // Database Password
 $db_name = &quot;music&quot; ; // Database Name

 $db_link = mysql_connect(&quot;$db_host&quot;,&quot;$db_user&quot;,&quot;$db_password&quot;);
 mysql_select_db($db_name, $db_link);

?&gt;
 &lt;playlist version=&quot;1&quot; xmlns=&quot;http://xspf.org/ns/0/&quot;&gt;
 &lt;trackList&gt;
 &lt;?php
 $album_id = $_GET[aid];
 $songs = &quot;SELECT * From songs WHERE album_id='$album_id' ORDER BY song_title ASC&quot;;
 $songs_list = mysql_query( $songs, $db_link );
 $songs_total = mysql_num_rows( $songs_list );
 if( $songs_total == 0 )    {    exit;    }
 for( $f = 0; $f &lt; $songs_total; $f++ )
 {
 $each = mysql_fetch_assoc( $songs_list );
 ?&gt;
 &lt;track&gt;
 &lt;title&gt;&lt;?=$each['song_title']?&gt;&lt;/title&gt;
 &lt;location&gt;http://www.yourdomain.com/&lt;?=$each['song_link']?&gt;&lt;/location&gt;
 &lt;/track&gt;
 &lt;?php

 } // End of loop

 ?&gt;
 &lt;/trackList&gt;
 &lt;/playlist&gt;
</pre>
<p>Then you can use call this file with album id like <strong>xml.php?aid=10</strong>.</p>
<h3><a href="http://www.thetechspace.com/?download=php_xml_output" target="_blank">Download Source</a> ( size 745 B)</h3>
<div class="shr-publisher-279"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to parse xml in php?</title>
		<link>http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/</link>
		<comments>http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 08:33:46 +0000</pubDate>
		<dc:creator>Thurein</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.thetechspace.com/?p=256</guid>
		<description><![CDATA[When I started and learn php programming language. I have wanted to get data from xml file and read with php. I searched with Google. I got a lot of source codes. Some of codes are working in my local machine but when I upload and test it. It doesn&#8217;t work. I have found some [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>When I started and learn php programming language. I have wanted to get data from xml file and read with php. I searched with Google. I got a lot of source codes. Some of codes are working in my local machine but when I upload and test it. It doesn&#8217;t work. I have found some codes are work with almost all of server. I will share it back.</p>
<p><span id="more-256"></span>Firstly, I have created example xml file as songs.xml like :</p>
<pre class="brush:xml">

&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;

&lt;currentsongs&gt;
&lt;song&gt;
&lt;title&gt;Song Title One&lt;/title&gt;
&lt;artist&gt;artist name&lt;/artist&gt;

&lt;/song&gt;

&lt;song&gt;
&lt;title&gt;Song Title Two&lt;/title&gt;
&lt;artist&gt;Sec artist name&lt;/artist&gt;

&lt;/song&gt;
&lt;/currentsongs&gt;
</pre>
<p>Then in php file :</p>
<pre class="brush:php">
&lt;?php

$objDOM = new DOMDocument();
$objDOM-&gt;load("songs.xml"); //make sure path is correct

$songs = $objDOM-&gt;getElementsByTagName("song");

foreach( $songs as $value )
{
$title = $value-&gt;getElementsByTagName("title");
$song_title  = $title-&gt;item(0)-&gt;nodeValue;

$artist = $value-&gt;getElementsByTagName("artist");
$artist_name  = $artist-&gt;item(0)-&gt;nodeValue;

echo "$song_title - $artist_name &lt;br&gt;";
}

?&gt;
</pre>
<h3><a href="http://www.thetechspace.com/?download=php_xml_read" target="_blank">Download Source</a> ( size 868 B)</h3>
<div class="shr-publisher-256"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

