views:

23

answers:

3

When Google Analytics return data, it is in XML:

(this is just for the data of IE. there is also data for Firefox, Safari, etc, for the pageview counts)

    <entry gd:etag='W/&quot;AkMEQX47eSp7I2A9Wx5SE3Z.&quot;' gd:kind='analytics#datarow'>
            <id>http://www.google.com/analytics/feeds/data?ids=ga:1234567&amp;amp;ga:browser=Internet%20Explorer&amp;amp;start-date=2010-08-03&amp;amp;end-date=2010-08-10&lt;/id&gt;
            <updated>2010-08-09T17:00:00.001-07:00</updated>
            <title>ga:browser=Internet Explorer</title>
            <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/&gt;
            <dxp:dimension name='ga:browser' value='Internet Explorer'/>
            <dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='276395'/>
    </entry>

Is there a way to quickly view it in a nice table format? Such as by applying a CSS to it? Seems like Google Analytics can possibly provide a CSS file that works well with their datafeed?

+1  A: 

You can use an XSL transform to convert this XML structure into an XHTML structure that you can view in a browser. If you haven't used XSL before, here's some resources to help you get started:

kbrimington
+1  A: 

If you would be interested in doing this through Javascript, Yahoo User Interface (YUI) toolkit has a data table utility that takes XML as its input, does some nice formatting, and provides controls.

Jeremy DeGroot
+1  A: 

CSS could do something with it, especially in those browsers that implement the features required to take an attribute value as the value to a content rule.

However, it will only go so far (pretty much as far as you could go if the above were some new HTML elements, and you were CSSing for it, it's essentially the same thing).

Using XSLT to produce XHTML is a much more reasonable solution. So reasonable in fact that I'm guessing you don't know XSLT simply from it not already occurring to you before CSS did. It's a nice declarative language for turning one form of XML into another (the output doesn't have to be XML, but it often is - I'm just adding this parenthetical statement to head off the person who'll add "the output doesn't have to be XML" as a comment to this post ;)

The third alternative is just to parse through it in your language of choice, simply because that'll probably be easier as a one-off than learning XSLT. However, learning XSLT will likely pay the effort back pretty quickly, so that's my real suggestion.

Jon Hanna