Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Edit:</strong> <em>Arend is right, the problem is just SimpleXML handling the namespaces strangely.</em></p> <p>You might need to pass the entire XML response to the SimpleXMLElement() constructor, not just the snippet you provided here. In particular you need the <code>&lt;feed&gt;</code> element because it has the namespace declarations:</p> <pre><code>&lt;feed xmlns='http://www.w3.org/2005/Atom' xmlns:dxp='http://schemas.google.com/analytics/2009' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/&amp;quot;DUINSHcycSp7I2A9WxRWFEQ.&amp;quot;' gd:kind='analytics#data'&gt; &lt;entry gd:etag="W/&amp;quot;hdSFEs.&amp;quot;" gd:kind="analytics#datarow"&gt; &lt;id&gt;http://www.google.com/analytics/feeds/data?ids=ga:430&amp;amp;ga:keyword=cats&amp;amp;start-date=2011-04-10&amp;amp;end-date=2011-07-24&lt;/id&gt; &lt;updated&gt;2011-07-23T17:00:00.001-07:00&lt;/updated&gt; &lt;title&gt;ga:keyword=cats&lt;/title&gt; &lt;link rel="alternate" type="text/html" href="http://www.google.com/analytics"/&gt; &lt;dxp:dimension name="ga:keyword" value="cats"/&gt; &lt;dxp:metric confidenceInterval="0.0" name="ga:organicSearches" type="integer" value="2"/&gt; &lt;/entry&gt; &lt;/feed&gt; </code></pre> <p>Without these namespace declarations it looks like your XML library is dropping any namespaced attributes or elements (such as <code>&lt;dxp:metric&gt;</code>).</p> <p>You might also get different results from a different version of the XML library. On my system your snippet produces a SimpleXMLElement with all of the attributes and elements, including <code>&lt;metric&gt;</code>, though I do get a bunch of PHP warnings complaining about the missing namespace declarations.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload