<?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: SimpleXML and namespaces</title>
	<atom:link href="http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/</link>
	<description>News, opinion, and fresh thinking for web developers and designers. The official podcast of sitepoint.com.</description>
	<lastBuildDate>Sun, 14 Mar 2010 10:01:45 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Adrian Smith</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-876001</link>
		<dc:creator>Adrian Smith</dc:creator>
		<pubDate>Mon, 09 Feb 2009 16:23:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-876001</guid>
		<description>That&#039;s brilliant, thanks a lot!</description>
		<content:encoded><![CDATA[<p>That&#8217;s brilliant, thanks a lot!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: mtorbin</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-853251</link>
		<dc:creator>mtorbin</dc:creator>
		<pubDate>Tue, 23 Dec 2008 15:02:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-853251</guid>
		<description>Kevin, great article!  This helped a lot.  Question for you: how would I handle multiple namespace prefixes, such as the following:

[item:group]
    [widget:typeA attr1=&quot;&quot; attr2=&quot;&quot;/]
[/item:group]

If I wanted to get the values of attribute one and two of the widget, how would that be done?

Thanks,

 - MT</description>
		<content:encoded><![CDATA[<p>Kevin, great article!  This helped a lot.  Question for you: how would I handle multiple namespace prefixes, such as the following:</p>
<p>[item:group]<br />
    [widget:typeA attr1="" attr2=""/]<br />
[/item:group]</p>
<p>If I wanted to get the values of attribute one and two of the widget, how would that be done?</p>
<p>Thanks,</p>
<p> &#8211; MT</p>]]></content:encoded>
	</item>
	<item>
		<title>By: mtorbin</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-853249</link>
		<dc:creator>mtorbin</dc:creator>
		<pubDate>Tue, 23 Dec 2008 15:01:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-853249</guid>
		<description>Kevin, great article!  This helped a lot.  Question for you: how would I handle multiple namespace prefixes, such as the following:



    



If I wanted to get the values of attribute one and two of the widget, how would that be done?

Thanks,

 - MT</description>
		<content:encoded><![CDATA[<p>Kevin, great article!  This helped a lot.  Question for you: how would I handle multiple namespace prefixes, such as the following:</p>
<p>If I wanted to get the values of attribute one and two of the widget, how would that be done?</p>
<p>Thanks,</p>
<p> &#8211; MT</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-789491</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Sun, 31 Aug 2008 16:48:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-789491</guid>
		<description>Great article.  I have been trying to get a value from a node with a namespace for quite some time now and couldn&#039;t quite figure it out.

Thanks.</description>
		<content:encoded><![CDATA[<p>Great article.  I have been trying to get a value from a node with a namespace for quite some time now and couldn&#8217;t quite figure it out.</p>
<p>Thanks.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Crashdaddy</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-602137</link>
		<dc:creator>Crashdaddy</dc:creator>
		<pubDate>Sun, 13 Jan 2008 22:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-602137</guid>
		<description>That&#039;s definitely &lt;em&gt;dugg&lt;/em&gt;.  Thank you!</description>
		<content:encoded><![CDATA[<p>That&#8217;s definitely <em>dugg</em>.  Thank you!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: whatever</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-533595</link>
		<dc:creator>whatever</dc:creator>
		<pubDate>Mon, 03 Dec 2007 19:31:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-533595</guid>
		<description>is there a way to escape &quot;&quot; in xml file only. I want those characters to be recognized in html though.</description>
		<content:encoded><![CDATA[<p>is there a way to escape &#8220;&#8221; in xml file only. I want those characters to be recognized in html though.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-431430</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 31 Oct 2007 20:23:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-431430</guid>
		<description>SimpleXML and namespaces are sooo gay. This should be handled the same as non-namespaced attributes.</description>
		<content:encoded><![CDATA[<p>SimpleXML and namespaces are sooo gay. This should be handled the same as non-namespaced attributes.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: greg bass</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-222008</link>
		<dc:creator>greg bass</dc:creator>
		<pubDate>Tue, 10 Apr 2007 17:53:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-222008</guid>
		<description>Kevin,
Thank you for this article.  I bought the book previously and this missing topic is just what I&#039;m stuck on.  If you could indulge my ignorance, I am still stuck on how to parse multiple namespace items with multiple attributes on the same level. I am trying to parse the yahoo weather rss feed:

&lt;channel&gt;
...
  &lt;yweather:location city=&quot;Tombstone&quot; region=&quot;Arizona&quot; country=&quot;US&quot;&gt;&lt;yweather:location&gt;
...
  &lt;yweather:astronomy sunrise=&quot;7:02am&quot; sunset=&quot;4:51pm&quot;&gt;&lt;yweather:astronomy&gt;
...
&lt;channel&gt;

how do I get to sunrise for instance? $sunrise = ?
Thanks!</description>
		<content:encoded><![CDATA[<p>Kevin,<br />
Thank you for this article.  I bought the book previously and this missing topic is just what I&#8217;m stuck on.  If you could indulge my ignorance, I am still stuck on how to parse multiple namespace items with multiple attributes on the same level. I am trying to parse the yahoo weather rss feed:</p>
<p>&lt;channel&gt;<br />
&#8230;<br />
  &lt;yweather:location city=&quot;Tombstone&quot; region=&quot;Arizona&quot; country=&quot;US&quot;&gt;&lt;yweather:location&gt;<br />
&#8230;<br />
  &lt;yweather:astronomy sunrise=&quot;7:02am&quot; sunset=&quot;4:51pm&quot;&gt;&lt;yweather:astronomy&gt;<br />
&#8230;<br />
&lt;channel&gt;</p>
<p>how do I get to sunrise for instance? $sunrise = ?<br />
Thanks!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Yank</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-214032</link>
		<dc:creator>Kevin Yank</dc:creator>
		<pubDate>Thu, 29 Mar 2007 02:52:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-214032</guid>
		<description>Anonymous,

Sure -- just use the getNamespaces method: http://www.php.net/manual/en/function.simplexml-element-getNamespaces.php</description>
		<content:encoded><![CDATA[<p>Anonymous,</p>
<p>Sure &#8212; just use the getNamespaces method: <a href="http://www.php.net/manual/en/function.simplexml-element-getNamespaces.php" rel="nofollow">http://www.php.net/manual/en/function.simplexml-element-getNamespaces.php</a></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-213996</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Thu, 29 Mar 2007 01:33:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-213996</guid>
		<description>Is there any way to (automatically) get the xmlns:dc URL from the code?  I&#039;d like to find the URI in code, but all examples have it hard-coded.</description>
		<content:encoded><![CDATA[<p>Is there any way to (automatically) get the xmlns:dc URL from the code?  I&#8217;d like to find the URI in code, but all examples have it hard-coded.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: joeblow</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-32030</link>
		<dc:creator>joeblow</dc:creator>
		<pubDate>Thu, 22 Jun 2006 19:23:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-32030</guid>
		<description>Is there any way to see what is contained in the buffer for $channel_itunes in the above example. I have tried the Zend debugger but is just states &quot;Object of: SimpleXMLElement&quot; and print_r gives me an empty SimpleXMLElement Object. If I could see the data that was contained in the buffer, I would be able to more accurately troubleshoot problems I was having without guessing as I am now.

Thanks.</description>
		<content:encoded><![CDATA[<p>Is there any way to see what is contained in the buffer for $channel_itunes in the above example. I have tried the Zend debugger but is just states &#8220;Object of: SimpleXMLElement&#8221; and print_r gives me an empty SimpleXMLElement Object. If I could see the data that was contained in the buffer, I would be able to more accurately troubleshoot problems I was having without guessing as I am now.</p>
<p>Thanks.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: joeblow</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-31716</link>
		<dc:creator>joeblow</dc:creator>
		<pubDate>Wed, 21 Jun 2006 15:07:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-31716</guid>
		<description>&lt;channel&gt;
    &lt;itunes:image href=&quot;some.link.com&quot; type=&quot;video&quot;&gt;
&lt;

I actually figured out the solution using your documentation and some experimentation.

foreach($rss-&gt;channel as $channel)
{
    $channel_itunes = $channel-&gt;children(’http://www.itunes.com/dtds/podcast-1.0.dtd’);
    $image_items = $channel_itunes-&gt;attributes();
    $image = $image_items[&#039;href&#039;];
}</description>
		<content:encoded><![CDATA[<p>&lt;channel&gt;<br />
    &lt;itunes:image href=&#8221;some.link.com&#8221; type=&#8221;video&#8221;&gt;<br />
&lt;</p>
<p>I actually figured out the solution using your documentation and some experimentation.</p>
<p>foreach($rss-&gt;channel as $channel)<br />
{<br />
    $channel_itunes = $channel-&gt;children(’http://www.itunes.com/dtds/podcast-1.0.dtd’);<br />
    $image_items = $channel_itunes-&gt;attributes();<br />
    $image = $image_items['href'];<br />
}</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Yank</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-31546</link>
		<dc:creator>Kevin Yank</dc:creator>
		<pubDate>Tue, 20 Jun 2006 23:06:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-31546</guid>
		<description>joeblow,

Could you post your code sample again and escape your special characters (e.g. &lt;)?</description>
		<content:encoded><![CDATA[<p>joeblow,</p>
<p>Could you post your code sample again and escape your special characters (e.g. &amp;lt;)?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: joeblow</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-31462</link>
		<dc:creator>joeblow</dc:creator>
		<pubDate>Tue, 20 Jun 2006 13:46:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-31462</guid>
		<description>What about a line that has both a namespace and an attribute such as the following:

[broken code sample removed -Ed]

How would I grab the itunes:image reference in the preceding xml? 
I&#039;ve tried the following code snippet to no avail(and many others):

foreach($rss-&gt;channel as $channel)
{
	$channel_itunes = $channel-&gt;children(&#039;http://www.itunes.com/dtds/podcast-1.0.dtd&#039;);
	$image = $channel_itunes-&gt;image[&#039;url&#039;];
}

Any help would be greatly appreciated.</description>
		<content:encoded><![CDATA[<p>What about a line that has both a namespace and an attribute such as the following:</p>
<p>[broken code sample removed -Ed]</p>
<p>How would I grab the itunes:image reference in the preceding xml?<br />
I&#8217;ve tried the following code snippet to no avail(and many others):</p>
<p>foreach($rss-&gt;channel as $channel)<br />
{<br />
	$channel_itunes = $channel-&gt;children(&#8217;http://www.itunes.com/dtds/podcast-1.0.dtd&#8217;);<br />
	$image = $channel_itunes-&gt;image['url'];<br />
}</p>
<p>Any help would be greatly appreciated.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: the rasx() context &#187; Blog Archive &#187; KB Research Links</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-12694</link>
		<dc:creator>the rasx() context &#187; Blog Archive &#187; KB Research Links</dc:creator>
		<pubDate>Fri, 13 Jan 2006 19:34:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-12694</guid>
		<description>[...] This article reveals the ‘special’ steps one has to take to read XML in PHP 5 containing namespaces—more psychological support with a bit more technical help. Another article, “XML Namespaces” does more of the same. [...]</description>
		<content:encoded><![CDATA[<p>[...] This article reveals the ‘special’ steps one has to take to read XML in PHP 5 containing namespaces—more psychological support with a bit more technical help. Another article, “XML Namespaces” does more of the same. [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Ian</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-10123</link>
		<dc:creator>Ian</dc:creator>
		<pubDate>Sat, 22 Oct 2005 14:03:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-10123</guid>
		<description>Thanks for the pointers Kevin!</description>
		<content:encoded><![CDATA[<p>Thanks for the pointers Kevin!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Yank</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-10085</link>
		<dc:creator>Kevin Yank</dc:creator>
		<pubDate>Fri, 21 Oct 2005 01:34:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-10085</guid>
		<description>Hmm okay. To get at the &lt;code&gt;rdf:resource&lt;/code&gt; attribute in the &lt;code&gt;rdf:li&lt;/code&gt; tag in the example above:

&lt;pre&gt;&lt;code class=&quot;php&quot;&gt;
$feed = simplexml_load_file(&#039;http://www.sitepoint.com/recent.rdf&#039;);
$items = $feed-&gt;channel-&gt;items;
$items_rdf = $items-&gt;children(&#039;http://www.w3.org/1999/02/22-rdf-syntax-ns#&#039;);
$Seq_rdf = $items_rdf-&gt;Seq-&gt;children(&#039;http://www.w3.org/1999/02/22-rdf-syntax-ns#&#039;);
$lis = $Seq_rdf-&gt;li;
foreach ($lis as $li) { 
  $li_attr_rdf = $li-&gt;attributes(&#039;http://www.w3.org/1999/02/22-rdf-syntax-ns#&#039;);
  $resource = $li_attr_rdf[&#039;resource&#039;];
  echo $resource . &quot;\n&quot;;
}
&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hmm okay. To get at the <code>rdf:resource</code> attribute in the <code>rdf:li</code> tag in the example above:</p>
<pre><code class="php">
$feed = simplexml_load_file('http://www.sitepoint.com/recent.rdf');
$items = $feed->channel->items;
$items_rdf = $items->children('http://www.w3.org/1999/02/22-rdf-syntax-ns#');
$Seq_rdf = $items_rdf->Seq->children('http://www.w3.org/1999/02/22-rdf-syntax-ns#');
$lis = $Seq_rdf->li;
foreach ($lis as $li) { 
  $li_attr_rdf = $li->attributes('http://www.w3.org/1999/02/22-rdf-syntax-ns#');
  $resource = $li_attr_rdf['resource'];
  echo $resource . &quot;\n&quot;;
}
</code></pre>]]></content:encoded>
	</item>
	<item>
		<title>By: Ian</title>
		<link>http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/comment-page-1/#comment-10084</link>
		<dc:creator>Ian</dc:creator>
		<pubDate>Fri, 21 Oct 2005 00:37:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/#comment-10084</guid>
		<description>Could we please have an example for the attributes please? I have failed to use the attributes method to get at a name spaced attribute contained in a name spaced element (and caused my scalp to bleed in the process!!!). In the end I regex&#039;ed out the attribute to its own element so I could get SimpleXML to work; &lt;em&gt;not so simple&lt;/em&gt;!</description>
		<content:encoded><![CDATA[<p>Could we please have an example for the attributes please? I have failed to use the attributes method to get at a name spaced attribute contained in a name spaced element (and caused my scalp to bleed in the process!!!). In the end I regex&#8217;ed out the attribute to its own element so I could get SimpleXML to work; <em>not so simple</em>!</p>]]></content:encoded>
	</item>
</channel>
</rss>
