Just curious how to obtain the information from "startTime" of this xml document using php and simplexml
<event xmlns="http开发者_运维知识库://schemas.google.com/contact/2008" xmlns:default="http://schemas.google.com/g/2005" rel="anniversary">
<default:when xmlns="http://schemas.google.com/g/2005" startTime="2009-05-09"/>
</event>
My initial thought was.
$xml->event->default['startTime']
OR
$xml->event->when['startTime']
But both return NULL... when I can see the data isn't NULL. Any thoughts on how to obtain this information?
Well after much more research I found this as a result and is working perfectly.
// Get All Events
foreach ($xml->event as $e) {
$defaults = $e->children('http://schemas.google.com/g/2005');
if($e['rel'] == "anniversary") {
$obj->anniversary = (string) $defaults->when->attributes()->startTime;
}
}
精彩评论