<?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>Negative Margins &#187; php</title>
	<atom:link href="http://www.negativemargins.com/category/programming/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.negativemargins.com</link>
	<description>Adventures in css, javascript, and all things web</description>
	<lastBuildDate>Mon, 03 May 2010 00:43:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP: Mixing SimpleXML and json_encode</title>
		<link>http://www.negativemargins.com/2007/10/02/php-mixing-simplexml-and-json_encode/</link>
		<comments>http://www.negativemargins.com/2007/10/02/php-mixing-simplexml-and-json_encode/#comments</comments>
		<pubDate>Tue, 02 Oct 2007 18:15:37 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.negativemargins.com/2007/10/02/php-mixing-simplexml-and-json_encode/</guid>
		<description><![CDATA[Recently, I've been doing a lot of work with XML and json. One small problem I ran into was assigning SimpleXML variables to a class variable and then running it through json_encode:
"pageLength":{"0":"10"}
The simple solution I came up with, but which were not readily apparent in the documentation is that you need to simply cast the [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I've been doing a lot of work with XML and json. One small problem I ran into was assigning SimpleXML variables to a class variable and then running it through json_encode:</p>
<p><em>"pageLength":{"0":"10"}</em></p>
<p>The simple solution I came up with, but which were not readily apparent in the documentation is that you need to simply cast the SimpleXML variable to a string or int.</p>
<p><em>$object-&gt;pageLength = (int)$xml-&gt;element;</em></p>
<p>which produces this json:</p>
<p><em>"pageLength":0</em></p>
<p>Hope this helps someone else save some time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.negativemargins.com/2007/10/02/php-mixing-simplexml-and-json_encode/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
