2011-07-23 11 views
1

私はカールを使用してGoogleアナリティクスデータにアクセスしています。simplexmlまたはxmldomを使用してxmlエントリのGoogleアナリティクス応答xmlにアクセスできません

レスポンステキストには、次のようなものが含まれています。寸法・< DXP::私はgetglementsbytagnameを使用してのSimpleXMLとphpdomxmlを使用してみましたが、それでも私は、そのノードに到達couldntの

メートル以上で

<entry gd:etag='W/&quot;A0EEQX47eSp7I2A9WhZSFU8.&quot;' gd:kind='analytics#datarow'> 
     <id>http://www.google.com/analytics/feeds/data?ids=ga:176&amp;ga:pagePath=/indian-language-unicode-converter/punjabi-unicode-converter.html&amp;start-date=2011-03-01&amp;end-date=2011-03-31</id> 
     <updated>2011-03-30T17:00:00.001-07:00</updated> 
     <title>ga:pagePath=/indian-language-unicode-converter/punjabi-unicode-converter.html</title> 

     <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/> 
     <dxp:dimension name='ga:pagePath' value='/indian-language-unicode-converter/punjabi-unicode-converter.html'/> 
     <dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='1131'/> 
    </entry> 
    <entry gd:etag='W/&quot;A0EEQX47eSp7I2A9WhZSFU8.&quot;' gd:kind='analytics#datarow'> 
     <id>http://www.google.com/analytics/feeds/data?ids=ga:76&amp;ga:pagePath=/indian-language-unicode-converter/hindi-unicode-converter.html&amp;start-date=2011-03-01&amp;end-date=2011-03-31</id> 
     <updated>2011-03-30T17:00:00.001-07:00</updated> 

     <title>ga:pagePath=/indian-language-unicode-converter/hindi-unicode-converter.html</title> 
     <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/> 
     <dxp:dimension name='ga:pagePath' value='/indian-language-unicode-converter/hindi-unicode-converter.html'/> 
     <dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='974'/> 
    </entry> 

iは< DXPにアクセスしたいです。

誰かがいいだろうという、そので私を助けることができれば...ちょうどロジック..

とこの表記がXML DXPにあるもの以外:ディメンション?

答えて

0

dxp:は名前空間です。より詳細な説明はここで見つけることができます:dxp namespace in the results xml feed

あなたがPHPを使用している場合は、これと同様の機能を試すことができます:

function parse_data($xml){ 
$doc = new DOMDocument(); 
$doc->loadXML($xml); 

$entries = $doc->getElementsByTagName('entry'); 
$i = 0; 
$results = array(); 
foreach($entries as $entry) 
{ 
    $countries[$i] = array(); 

    $dimensions = $entry->getElementsByTagName('dimension'); 
    foreach($dimensions as $dimension) 
    { 
     $results[$i][ltrim($dimension->getAttribute("name"),"ga:")] = $dimension->getAttribute('value'); 
    } 

    $metrics = $entry->getElementsByTagName('metric'); 
    foreach($metrics as $metric) 
    { 
     $results[$i][ltrim($metric->getAttribute('name'),"ga:")] = $metric->getAttribute('value'); 
    } 

    $i++; 
} 
return $results; 
} 

をアレックスCureleaによって、次のポストは非常に有用である:Using the Google Analytics API - getting total number of page views