Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 852053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:31:50+00:00 2026-05-15T07:31:50+00:00

I am trying to retrieve the XML data for Google Calendar. Authentication and retrieval

  • 0

I am trying to retrieve the XML data for Google Calendar. Authentication and retrieval all works. However, when I retrieve the events, gd: data isn’t included as the protocol reference documents it would be (http://code.google.com/apis/calendar/data/2.0/developers_guide_protocol.html#RetrievingWithoutQuery)

Some error messages I’m running into depending on how I’m referencing the “when” node with attribute “startTime” (my ultimate goal in this anecdote) are as follows:

Fatal error: Call to a member function attributes() on a non-object in …/googlecalendarwrapper.php on line 226
when it looks like 'startTime'=> (string) $cal->when->attributes()->startTime,

GoogleCalendarWrapper_Model::getEventsList() [googlecalendarwrapper-model.geteventslist]: Node no longer exists when it looks like 'startTime'=> strval($cal->when->attributes()->startTime),

strval() [function.strval]: Node no longer exists when it looks like 'startTime'=> strval($cal->when->attributes()), and 'startTime'=> strval($cal->when->attributes('startTime')),

Code looks like:

            $xml = new SimpleXMLElement($this->get($url, $header));

            $calendars = array();
            foreach ($xml->entry as $cal){
                    $calendars[] = array(                            
                                                         'id'=>strval($cal->id),
                                                         'published'=>strval($cal->published),
                                                         'updated'=>strval($cal->updated),
                                                         'title'=>strval($cal->title),
                                                         'content'=>strval($cal->content),
                                                         'link'=>strval($cal->link->attributes()->href),
                                                         'authorName'=>strval($cal->author->name),
                                                         'authorEmail'=>strval($cal->author->email),
                                                         'startTime'=> strval($cal->when->attributes()),
                                                        );
            }

XML:

        [0] => SimpleXMLElement Object
            (
                [id] => http://www.google.com/calendar/feeds/braden.keith%40smartersys.com/private/full/7li4mr2c81mub1hcoqktn73fbo
                [published] => 2010-06-08T17:17:43.000Z
                [updated] => 2010-06-08T17:17:43.000Z
                [category] => SimpleXMLElement Object
                    (
                        [@attributes] => Array
                            (
                                [scheme] => http://schemas.google.com/g/2005#kind
                                [term] => http://schemas.google.com/g/2005#event
                            )

                    )

                [title] => title
                [content] => content
                [link] => Array
                    (
                        [0] => SimpleXMLElement Object
                            (
                                [@attributes] => Array
                                    (
                                        [rel] => alternate
                                        [type] => text/html
                                        [href] => https://www.google.com/calendar/hosted/smartersys.com/event?eid=N2xpNG1yMmM4MW11YjFoY29xa3RuNzNmYm8gYnJhZGVuLmtlaXRoQHNtYXJ0ZXJzeXMuY29t
                                        [title] => alternate
                                    )

                            )

                        [1] => SimpleXMLElement Object
                            (
                                [@attributes] => Array
                                    (
                                        [rel] => self
                                        [type] => application/atom+xml
                                        [href] => https://www.google.com/calendar/feeds/braden.keith%40smartersys.com/private/full/7li4mr2c81mub1hcoqktn73fbo
                                    )

                            )

                        [2] => SimpleXMLElement Object
                            (
                                [@attributes] => Array
                                    (
                                        [rel] => edit
                                        [type] => application/atom+xml
                                        [href] => https://www.google.com/calendar/feeds/braden.keith%40smartersys.com/private/full/7li4mr2c81mub1hcoqktn73fbo/63411700663
                                    )

                            )

                    )

                [author] => SimpleXMLElement Object
                    (
                        [name] => Braden Keith
                        [email] => braden.keith@smartersys.com
                    )

            )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:31:50+00:00Added an answer on May 15, 2026 at 7:31 am

    According to this article: http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/
    You have to approach namespaces a tad differently with SimpleXMLElement. The solution is as follows:

                $xml = new SimpleXMLElement($this->get($url, $header));
                $xml->asXML();
    
                $calendars = array();
                foreach ($xml->entry as $cal){
                        $ns_gd = $cal->children('http://schemas.google.com/g/2005');
                        $calendars[] = array(                            
                                                             'id'=>strval($cal->id),
                                                             'published'=>strval($cal->published),
                                                             'updated'=>strval($cal->updated),
                                                             'title'=>strval($cal->title),
                                                             'content'=>strval($cal->content),
                                                             'link'=>strval($cal->link->attributes()->href),
                                                             'authorName'=>strval($cal->author->name),
                                                             'authorEmail'=>strval($cal->author->email),
                                                             'startTime'=> strval($ns_gd->when->attributes()->startTime),
                                                            );
                }
    

    Note the $ns_gd = $cal->children('http://schemas.google.com/g/2005'); – this defines the namespace. Then from there, $ns_gd->when->attributes()->startTime gets the attribute from gd:when named startTime.

    Man it’s been a bloody 2 days. But I figured it out. Hopefully this can help someone down the road.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.