Amazon AWS + SimpleXML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey guys,

I'm having trouble trying to parse XML results from an Alexa Web information
service from amazon.com, using SimpleXML.

Here is an example response:

<?xml version="1.0"?>
<aws:TrafficHistoryResponse
xmlns:aws="http://alexa.amazonaws.com/doc/2005-10-05/";><aws:Response
xmlns:aws="http://awis.amazonaws.com/doc/2005-07-11";><aws:OperationRequest><
aws:RequestId>cdfcc49c-5c01-4fc1-87e4-06f2f151e205</aws:RequestId></aws:Oper
ationRequest><aws:TrafficHistoryResult><aws:Alexa>
  
  <aws:TrafficHistory>
    <aws:Range>3</aws:Range>
    <aws:Site>amazon.com</aws:Site>
    <aws:Start>2007-03-15</aws:Start>
    <aws:HistoricalData>
      <aws:Data>
        <aws:Date>2007-03-15</aws:Date>
        <aws:PageViews>
          <aws:PerMillion>1491</aws:PerMillion>
          <aws:PerUser>5.7</aws:PerUser>
        </aws:PageViews>
        <aws:Rank>30</aws:Rank>
        <aws:Reach>
          <aws:PerMillion>17359</aws:PerMillion>
        </aws:Reach>
      </aws:Data>
      <aws:Data>
        <aws:Date>2007-03-16</aws:Date>
        <aws:PageViews>
          <aws:PerMillion>1531</aws:PerMillion>
          <aws:PerUser>6.0</aws:PerUser>
        </aws:PageViews>
        <aws:Rank>29</aws:Rank>
        <aws:Reach>
          <aws:PerMillion>16796</aws:PerMillion>
        </aws:Reach>
      </aws:Data>
      <aws:Data>
        <aws:Date>2007-03-17</aws:Date>
        <aws:PageViews>
          <aws:PerMillion>1411</aws:PerMillion>
          <aws:PerUser>5.6</aws:PerUser>
        </aws:PageViews>
        <aws:Rank>32</aws:Rank>
        <aws:Reach>
          <aws:PerMillion>16475</aws:PerMillion>
        </aws:Reach>
      </aws:Data>
    </aws:HistoricalData>
  </aws:TrafficHistory>
</aws:Alexa></aws:TrafficHistoryResult><aws:ResponseStatus
xmlns:aws="http://alexa.amazonaws.com/doc/2005-10-05/";><aws:StatusCode>Succe
ss</aws:StatusCode></aws:ResponseStatus></aws:Response></aws:TrafficHistoryR
esponse>


$xml = new SimpleXMLElement($result);
var_dump($xml); // produces: object(SimpleXMLElement)#1 (0) {}


I found these posts in the amazon developer forums:
http://developer.amazonwebservices.com/connect/thread.jspa?messageID=55124
http://developer.amazonwebservices.com/connect/thread.jspa?messageID=54000&#
54000

I've tried to register the namespace, but that didn't seem to help...

$xml->registerXPathNamespace( "aws",
	"http://alexa.amazonaws.com/doc/2005-10-05/"; );

var_dump($xml->xpath("//aws:Response")); // produces array(0){}

(I tried it with the other url as well, same result)

Any advice is much appreciated.

Thx,

Brad 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux