<?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>Connecting the dots... &#187; namespaced</title>
	<atom:link href="http://blog.rajatpandit.com/tag/namespaced/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rajatpandit.com</link>
	<description>Thoughts on Web Development, Infrastructure and Application Scalability</description>
	<lastBuildDate>Thu, 29 Dec 2011 13:21:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>SimpleXML and parsing namespaced attribute</title>
		<link>http://blog.rajatpandit.com/2009/01/25/simpelxml-and-parsing-namespaced-attribute/</link>
		<comments>http://blog.rajatpandit.com/2009/01/25/simpelxml-and-parsing-namespaced-attribute/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 19:12:01 +0000</pubDate>
		<dc:creator>rp</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[namespaced]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[simplexml]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.rajatpandit.com/?p=147</guid>
		<description><![CDATA[SimpleXML is really good, this is especially more from the heart as its coming from someone who spent a decent amount of time using DOM API to parse xml in...]]></description>
			<content:encoded><![CDATA[<p>SimpleXML is really good, this is especially more from the heart as its coming from someone who spent a decent amount of time using DOM API to parse xml in Java, though XPath was mostly a saviour. I usually get stuck when I there is an edge case or parsing some data format that I haven&#8217;t had to use. Recently I had to parse an XML feed which contained some attributes link this:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;a foo:param=&quot;bla&quot;&gt;Some sample text&lt;/a&gt;
</pre>
<p>Trying to access is using the following code didnt work for me:</p>
<pre class="brush: php; title: ; notranslate">
$attributes = $xml-&gt;a-&gt;attributes('foo');
echo $attributes['param'];
</pre>
<p>However as mentioned in the <a href="http://uk3.php.net/manual/en/function.simplexml-element-attributes.php">manual</a> I needed to explicitly specify that the attribute is prefixed using the second argument. The default value for the second argument is false.</p>
<pre class="brush: php; title: ; notranslate">
$attributes = $xml-&gt;a-&gt;attributes('foo', true);
echo $attributes['param'];
</pre>
<p>I spent a while trying to figure this out, hope this saves you some time. Btw <a href="http://en.wikipedia.org/wiki/SimpleXML">simpleXML</a> is awesome.</p>
<div id="in_post_ad_bottom_1" style="clear:both;margin:0;padding:0;"><div class="brp-bp-234">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-4254382394977039";
/* brp-234x60-bp */
google_ad_slot = "7787511801";
google_ad_width = 234;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div class="brp-bp-234">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-4254382394977039";
/* brp-234x60-BP-1 */
google_ad_slot = "9111022353";
google_ad_width = 234;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></div><div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.rajatpandit.com/2009/01/25/simpelxml-and-parsing-namespaced-attribute/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

