<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: PHP Array To XML</title>
	<atom:link href="http://maisonbisson.com/blog/post/11450/php-array-to-xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://maisonbisson.com/blog/post/11450/php-array-to-xml/</link>
	<description>A bunch of stuff I would have emailed you about.</description>
	<lastBuildDate>Mon, 23 Nov 2009 20:05:59 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Erwan</title>
		<link>http://maisonbisson.com/blog/post/11450/php-array-to-xml/comment-page-1/#comment-431539</link>
		<dc:creator>Erwan</dc:creator>
		<pubDate>Fri, 13 Nov 2009 15:56:56 +0000</pubDate>
		<guid isPermaLink="false">http://maisonbisson.com/blog/post/11450/#comment-431539</guid>
		<description>I&#039;m surprised that nobody responded to your post Chris Sloots!! This helped me so much...
thanks 2 years after... :p</description>
		<content:encoded><![CDATA[<p>I&#8217;m surprised that nobody responded to your post Chris Sloots!! This helped me so much&#8230;<br />
thanks 2 years after&#8230; :p</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Sloots</title>
		<link>http://maisonbisson.com/blog/post/11450/php-array-to-xml/comment-page-1/#comment-183124</link>
		<dc:creator>Chris Sloots</dc:creator>
		<pubDate>Mon, 08 Oct 2007 13:39:24 +0000</pubDate>
		<guid isPermaLink="false">http://maisonbisson.com/blog/post/11450/#comment-183124</guid>
		<description>May nbe this code fragment helps!


function array_to_xml($aArr, $sName, &amp;$item = null) {
	global $dom;
	
	if (is_null($item))
		$item = $dom-&gt;createElement($sName);
		
	// Loop thru each element
	foreach ($aArr as $key =&gt; $val) {
		if (is_array($val)) {
			// 
			$sub = $dom-&gt;createElement($key);
			$item-&gt;appendChild($sub);
			array_to_xml($val, $key, $sub);
		} else {
			// Add this item
			$sub = $dom-&gt;createElement($key, $val);
			$item-&gt;appendChild($sub);
		}
	}
		
	return $item;
}



$dom = new DOMDocument(&#039;1.0&#039;);
// create root element
$root = $dom-&gt;createElement(&#039;bsr&#039;);
$dom-&gt;appendChild($root);

// create child element
$info = $dom-&gt;createElement(&#039;info&#039;);
$root-&gt;appendChild($info);

$aRes = array(
			&#039;first&#039;=&gt;3,
			&#039;subarray&#039;=&gt; array(
					&#039;sub1&#039;=&gt;&#039;sub1&#039;,
					&#039;sub2&#039;=&gt;&#039;sub2&#039;,
					&#039;sub3&#039;=&gt;&#039;sub3&#039;
				)
			&#039;last&#039;
		};
		
		
$restree = array_to_xml($aRes, &#039;result&#039;);
$info-&gt;appendChild($restree);</description>
		<content:encoded><![CDATA[<p>May nbe this code fragment helps!</p>
<p>function array_to_xml($aArr, $sName, &amp;$item = null) {<br />
	global $dom;</p>
<p>	if (is_null($item))<br />
		$item = $dom-&gt;createElement($sName);</p>
<p>	// Loop thru each element<br />
	foreach ($aArr as $key =&gt; $val) {<br />
		if (is_array($val)) {<br />
			//<br />
			$sub = $dom-&gt;createElement($key);<br />
			$item-&gt;appendChild($sub);<br />
			array_to_xml($val, $key, $sub);<br />
		} else {<br />
			// Add this item<br />
			$sub = $dom-&gt;createElement($key, $val);<br />
			$item-&gt;appendChild($sub);<br />
		}<br />
	}</p>
<p>	return $item;<br />
}</p>
<p>$dom = new DOMDocument(&#8217;1.0&#8242;);<br />
// create root element<br />
$root = $dom-&gt;createElement(&#8217;bsr&#8217;);<br />
$dom-&gt;appendChild($root);</p>
<p>// create child element<br />
$info = $dom-&gt;createElement(&#8217;info&#8217;);<br />
$root-&gt;appendChild($info);</p>
<p>$aRes = array(<br />
			&#8216;first&#8217;=&gt;3,<br />
			&#8217;subarray&#8217;=&gt; array(<br />
					&#8217;sub1&#8242;=&gt;&#8217;sub1&#8242;,<br />
					&#8217;sub2&#8242;=&gt;&#8217;sub2&#8242;,<br />
					&#8217;sub3&#8242;=&gt;&#8217;sub3&#8242;<br />
				)<br />
			&#8216;last&#8217;<br />
		};</p>
<p>$restree = array_to_xml($aRes, &#8216;result&#8217;);<br />
$info-&gt;appendChild($restree);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Nagy</title>
		<link>http://maisonbisson.com/blog/post/11450/php-array-to-xml/comment-page-1/#comment-79462</link>
		<dc:creator>Andrew Nagy</dc:creator>
		<pubDate>Mon, 18 Sep 2006 18:49:24 +0000</pubDate>
		<guid isPermaLink="false">http://maisonbisson.com/blog/post/11450/#comment-79462</guid>
		<description>I suggest taking a look at the PEAR package, it may be a bit heafty, but it is very worth while.[tags]PEAR, XML_Serializer[/tags]</description>
		<content:encoded><![CDATA[<p>I suggest taking a look at the PEAR package, it may be a bit heafty, but it is very worth while.</p>
<p>[tags]PEAR, XML_Serializer[/tags]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Scott</title>
		<link>http://maisonbisson.com/blog/post/11450/php-array-to-xml/comment-page-1/#comment-79441</link>
		<dc:creator>Dan Scott</dc:creator>
		<pubDate>Mon, 18 Sep 2006 17:36:48 +0000</pubDate>
		<guid isPermaLink="false">http://maisonbisson.com/blog/post/11450/#comment-79441</guid>
		<description>I agree with you on phpclasses.org; it appears a little bit too informal for my liking -- and while the rather strict coding standards that PEAR requires for acceptance of packages can be a barrier for the contributing developer, I&#039;ve found in my ongoing development for File_MARC (http://marc.coffeecode.net) that those guidelines have really increased my faith in the general quality of the code maintained by the PEAR project. The review comments I have received so far have already helped improve my package proposals.[tags]PEAR[/tags]</description>
		<content:encoded><![CDATA[<p>I agree with you on phpclasses.org; it appears a little bit too informal for my liking &#8212; and while the rather strict coding standards that PEAR requires for acceptance of packages can be a barrier for the contributing developer, I&#8217;ve found in my ongoing development for File_MARC (<a href="http://marc.coffeecode.net" rel="nofollow">http://marc.coffeecode.net</a>) that those guidelines have really increased my faith in the general quality of the code maintained by the PEAR project. The review comments I have received so far have already helped improve my package proposals.</p>
<p>[tags]PEAR[/tags]</p>
]]></content:encoded>
	</item>
</channel>
</rss>