<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Wed, 22 May 2013 20:31:22 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[PHPMaster.com: Parsing XML With SimpleXML]]></title>
      <guid>http://www.phpdeveloper.org/news/19171</guid>
      <link>http://www.phpdeveloper.org/news/19171</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new tutorial <a href="http://phpmaster.com/parsing-xml-with-simplexml/">introducing you to SimpleXML</a>, a handy bit of functionality included with the base PHP install to make working with XML (well, reading it) much simpler.
</p>
<blockquote>
Parsing XML essentially means navigating through an XML document and returning the relevant data. An increasing number of web services return data in JSON format, but a large number still return XML, so you need to master parsing XML if you really want to consume the full breadth of APIs available. Using PHP's SimpleXML extension that was introduced back in PHP 5.0, working with XML is very easy to do. In this article I'll show you how.
</blockquote>
<p>
He starts with some basic usage of the SimpleXML parsing, giving an example XML to parse, the resulting object and how to access the data inside it. There's also a bit about dealing with namespaces in the XML you're parsing and a more practical example - parsing the output of a YouTube feed to get links to various videos.
</p>]]></description>
      <pubDate>Tue, 12 Feb 2013 12:48:34 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Bending XML to Your Will]]></title>
      <guid>http://www.phpdeveloper.org/news/17453</guid>
      <link>http://www.phpdeveloper.org/news/17453</link>
      <description><![CDATA[<p>
PHPMaster.com has a new tutorial posted today about <a href="http://phpmaster.com/bending-xml-to-your-will/">"bending XML to your will"</a> - working with XML data using the <a href="http://us.php.net/manual/en/ref.xml.php">XML Parser</a> and <a href="http://php.net/simplexml">SimpleXML</a> functionality already included with PHP.
</p>
<blockquote>
If you've ever worked with the Twitter or Facebook APIs, looked at RSS feeds from a website, or made use of some type of RPC calls, you've undoubtedly experienced working with XML. [...] Knowing how to process XML data is a crucial programming skill today, and thankfully, PHP offers multiple ways to read, filter, and even generate XML. In this article I'll explain what exactly XML is, in case you haven't had any experience with it yet, and then dive into a few ways you can use PHP to bend XML to your will.
</blockquote>
<p>
He introduces the concepts and syntax behind XML first for those not accustomed and quickly moves into the tools to parse it. First he looks at the <a href="http://us.php.net/manual/en/ref.xml.php">XML Parser</a>, an event-based parser, and <a href="http://php.net/simplexml">SimpleXML</a>, an easy way to access the contents of a well-formed XML document. Snippets of code are provided for each to show you how to put them into practice.
</p>]]></description>
      <pubDate>Thu, 26 Jan 2012 11:04:44 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[SitePoint.com: How to Create an XML to JSON Proxy Server in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17016</guid>
      <link>http://www.phpdeveloper.org/news/17016</link>
      <description><![CDATA[<p>
On SitePoint.com today there's a new post from <i>Craig Buckler</i> showing you how to create a <a href="http://www.sitepoint.com/php-xml-to-json-proxy/">simple XML to JSON proxy server</a> in PHP with a SimpleXML object at its heart.
</p>
<blockquote>
Unless you're new to this web development lark, you'll know the 'X' in 'AJAX' stands for XML - eXtensible Markup Language. But you're probably not using XML. If you are, you'd probably prefer not to. All the cool kids are using JSON or JSON-P: it has a smaller payload, is easier to use and faster to process. [...] Fortunately, there are a couple of solutions which allow you to retain the benefits of XML data interchange but provide the ease of JSON in JavaScript. In this article, we're going to create an XML to JSON proxy server in PHP.
</blockquote>
<p>
Of course, this will only work with well-formatted XML documents, but it's a quick little hack that pulls in the XML data with a <a href="http://php.net/curl">curl</a> request and parses it via SimpleXML and uses <a href="http://php.net/json_encode">json_encode</a> to push it back out as JSON.
</p>
]]></description>
      <pubDate>Wed, 19 Oct 2011 13:07:08 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Enrico Zimuel's Blog: XML to JSON in PHP: an odyssey]]></title>
      <guid>http://www.phpdeveloper.org/news/16289</guid>
      <link>http://www.phpdeveloper.org/news/16289</link>
      <description><![CDATA[<p>
<i>Enrico Zimuel</i> as a new post to his blog today talking about his exploration of <a href="http://framework.zend.com/issues/browse/ZF-3257">a Zend Framework bug</a> related to the JSON handling of the Zend_Json component. The issue was related to the conversion of XML to JSON but it only happened in specific instances.
</p>
<blockquote>
As you can see the bar value, of the a element [in the example code], is not represented in JSON. This issue comes also with other XML documents, and in general when an XML node has a single character data child, any attributes are lost.
</blockquote>
<p>
In tracking down the issue, he followed a lead through a possible SimpleXML issue and, with some further testing, found a simple, non-Zend Framework script to behave the same way. It dropped the "bar" value of the example XML from the object's return value. To get around this bug, he created a new conversion algorithm that redefined the _processXML method in Zend_Json to work with the Zend_Json_Expr functionality to parse things more correctly. If you can't wait for the next release to get it into your codebase, you can <a href="http://www.zimuel.it/blog/2011/05/xml-to-json-in-php-an-odyssey/">grab the code from his post</a>.
</p>]]></description>
      <pubDate>Tue, 03 May 2011 12:05:09 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[iFadey.com: Get Flickr Images Using SimpleXML]]></title>
      <guid>http://www.phpdeveloper.org/news/15591</guid>
      <link>http://www.phpdeveloper.org/news/15591</link>
      <description><![CDATA[<p>
In <a href="http://www.ifadey.com/2010/04/get-flickr-images-using-simplexml/">this new post</a> to the iFadey blog, there's a quick tutorial on using SimpleXML to fetch and parse the image feeds from <a href="http://flickr.com">Flickr</a>.
</p>
<blockquote>
In this article you will learn two main things: how to parse XML using SimpleXML and how to get Flickr images from RSS feed and display them on your web page.
</blockquote>
<p>
He offers both <a href="http://www.ifadey.com/demos/03/index.php">a demo</a> of it in action and a <a href="http://www.ifadey.com/demos/03/source.zip">download of the source</a> for those that want to jump right in. The tutorial walks you through fetching the XML feed for a Flickr gallery, loading it into a SimpleXML object and creating a reusable class to pull out the photo titles, image details and profile link.
</p>]]></description>
      <pubDate>Thu, 16 Dec 2010 12:04:20 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: Google Analytics Accounts API]]></title>
      <guid>http://www.phpdeveloper.org/news/15477</guid>
      <link>http://www.phpdeveloper.org/news/15477</link>
      <description><![CDATA[<p>
In <a href="http://www.lornajane.net/posts/2010/Google-Analytics-Accounts-API">this new post</a> to her blog <i>Lorna Mitchell</i> looks at some of the work she's done to extract information out of the Google Analytics accounts API via an OAuth interface and parsed via SimpleXML.
</p>
<blockquote>
I'm using <a href="http://pecl.php.net/package/oauth">pecl_oauth</a> to authenticate users against their google accounts (see my post about <a href="http://www.lornajane.net/posts/2010/Authenticating-with-OAuth-from-PHP">using OAuth from PHP</a>), but even after I have a valid google user, working out which analytics accounts they have access to and how to refer to them is a puzzle in itself, so I thought I'd share what I learned.
</blockquote>
<p>
In her example she shows how to fetch the permissions for a user (which analytics they can access) via a call to the "/feeds/datasources/ga/accounts" URL. This returns some XML easily parsed by <a href="http://php.net/simplexml">SimpleXML</a> to grab the accounts' names and IDs. This is used to fetch the profiles and gather the "magic tableId" for use with the <a href="http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDataFeed.html">Export API</a> to pull the actual data.
</p>]]></description>
      <pubDate>Tue, 23 Nov 2010 10:56:35 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[CodingThis.com Blog: Quick XML-to-HTML Templating in PHP Using SimpleXML]]></title>
      <guid>http://www.phpdeveloper.org/news/15419</guid>
      <link>http://www.phpdeveloper.org/news/15419</link>
      <description><![CDATA[<p>
New on the CodingThis.com blog there's <a href="http://codingthis.com/programming/php/quick-xml-to-html-templating-in-php-using-simplexml/">a post about templating</a> using <a href="http://php.net/manual/en/book.simplexml.php">SimpleXML</a> to parse a basic XML file and push the data into a template.
</p>
<blockquote>
Since the API method interface is relatively static, I didn't need to generate it on the fly, so I created a PHP script. I could have used an XSL Transform (XSLT), but instead  I decided to use pure PHP. (I'd rather use PHP and realize I have too much power than use XSLT, and realize I don't have enough. Plus, I love PHP. There's no shame in sticking with what you know.) [...] The best package I found for my purposes is SimpleXML, which mimics the tree structure of an XML file as a series of embedded objects.
</blockquote>
<p>
He gives an example of some simple XML returned from his REST API, how <a href="http://php.net/simplexml_load_file">parsed it</a> and a foreach loop to go through the methods and output the HTML with the correct values. 
</p>]]></description>
      <pubDate>Thu, 11 Nov 2010 13:03:04 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: Fetching Namespaced XML Elements With SimpleXML]]></title>
      <guid>http://www.phpdeveloper.org/news/15383</guid>
      <link>http://www.phpdeveloper.org/news/15383</link>
      <description><![CDATA[<p>
<i>Lorna Mitchell</i> has a new post to her blog with a quick example of how to <a href="http://www.lornajane.net/posts/2010/Fetching-Namespaced-XML-Elements-With-SimpleXML">get namespaced values with SimpleXML</a> out of a properly formatted XML file.
</p>
<blockquote>
Recently I was working with some google APIs and needed to retrieve some namespaced elements from the result set. This confused me more than I expected it to so here's my code for the next time I need it (and if you use it too, then great!) I was reading from their <A href="http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDataFeed.html">analytics data feed API</a>, this returns a few key fields and then multiple <entry> tags, each with namespaced children.
</blockquote>
<p>
The trick is to grab the current document's namespaces (via <a href="http://php.net/manual/de/simplexmlelement.getNamespaces.php">getNamespaces</a>), finding the key for the ones you want and grabbing them <a href="http://www.php.net/manual/de/simplexmlelement.children.php">as children</a>.
</p>]]></description>
      <pubDate>Thu, 04 Nov 2010 10:48:14 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Komunitasweb.com: Showing the weather with PHP and Google Weather API]]></title>
      <guid>http://www.phpdeveloper.org/news/13206</guid>
      <link>http://www.phpdeveloper.org/news/13206</link>
      <description><![CDATA[<p>
On the Komunitasweb.com blog there's a <a href="http://komunitasweb.com/2009/09/showing-the-weather-with-php-and-google-weather-api/">recent post</a> walking you through the steps to add the Google weather content to your site, complete with icons.
</p>
<blockquote>
If you need to show weather in your website, you can use weather widget such as <a href="http://weather.weatherbug.com/desktop-weather/web-widgets.html">weatherbug</a>. It's nice and simple, but maybe you need something more integrated with your website. So, take a look at Google Weather API. 
</blockquote>
<p>
They use a <a href="http://php.net/simplexml">SimpleXML</a> object to pull in the XML data from Google's backend (as called via a URL) and loop through the resulting objects to output temperature, current conditions and several days of the forecast.
</p>]]></description>
      <pubDate>Fri, 11 Sep 2009 09:47:21 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Content with Style: Remove nodes in SimpleXMLElement]]></title>
      <guid>http://www.phpdeveloper.org/news/12885</guid>
      <link>http://www.phpdeveloper.org/news/12885</link>
      <description><![CDATA[<p>
The Content with Style blog has <a href="http://www.contentwithstyle.co.uk/content/remove-node-in-simplexml">this quick tip</a> on removing nodes from inside of a <a href="http://php.net/simplexml">SimpleXML</a> object without causing problems with its internal handling.
</p>
<blockquote>
You might think otherwise and hack it with unset(), as it was done in one of the web applications I inherited at work, but today I found out that this works under some conditions, but not with every setup. I'd love to tell you what exactly the differences are that make it break, but I didn't spend the time tracking it down.
</blockquote>
<p>
Instead, he suggests a call to <a href="http://php.net/dom_import_simplexml">dom_import_simplexml</a> to swap the object over to the DOM, performing a removeChild on the node and pushing it back over to SimpleXML if the need's there.
</p>]]></description>
      <pubDate>Thu, 16 Jul 2009 11:15:57 -0500</pubDate>
    </item>
  </channel>
</rss>
