I currently have this code.
<?php
$username = 'EMAIL ADDRESS';
$password = 'EMAIL ADDRESS';
$opts = array(
'http' => array(
'method' => 'GET',
'header' => sprintf("Authorization: Basic %s\r\nUser-Agent: Foobar!", base64_encode($username.':'.$password))
)
);
$context = stream_context_create($opts);
libxml_set_streams_context($context);
$xml = new SimpleXMLElement(
"https://mail.google.com/mail/feed/atom",
null,
true);
print_r($xml);
?>
And I get the following results when I run the PHP code
SimpleXMLElement Object ( [@attributes] => Array ( [version] => 0.3 ) [title] => Gmail – Inbox for EMAIL ADDRESS [tagline] => New messages in your Gmail Inbox [fullcount] => 1 [link] => SimpleXMLElement Object ( [@attributes] => Array ( [rel] => alternate [href] => http://mail.google.com/mail [type] => text/html ) ) [modified] => 2011-10-27T20:12:38Z [entry] => SimpleXMLElement Object ( [title] => SUBJECT [link] => SimpleXMLElement Object ( [@attributes] => Array ( [rel] => alternate [href] => LINK [type] => text/html ) ) [modified] => 2011-10-26T15:45:11Z [issued] => 2011-10-26T15:45:11Z [id] => tag:gmail.google.com,2004:1383746934228011210 [author] => SimpleXMLElement Object ( [name] => Webs [email] => EMAIL ) ) )
I want it so that the results do not display “SimpleXMLElement Object”, etc, and only display the actual useful info (subject, email content, date, etc)
I have tried using str_replace, but it doesn’t work.
Try something like:
You may need to add some extra paths to the above depending on the format of the XML.
You could also try
as in:
which outputs: