Parsing Google XML Calendar with JQuery

I am trying to parse a google calendar calendar like this:

<!DOCTYPE html>
  <script src=""></script>

<p id="entries"></p>


              url: '',
              dataType: 'xml',
              success: parseXML
        function parseXML(xml){
              $(xml).find('entry').each( function() {
                    $('#entries').append($(this).find('title').text() + '<br />')



But it won't find any items. What am I doing wrong? Tried the same code with a simpler XML file that worked ...


source to share

1 answer

When I tested myself, it seemed like it would not find any items because there was no data returned by the query. I thought that of course I was missing something due to the comments about incorrect encoding ... but I downloaded the XML document and saved it next to the HTML file you provided, making the following changes:

url: 'full.xml',
Having done this, (for me) the paragraph element is now populated with two entries, which can be seen in the XML targeting. Of course this is due to cross-domain policies, and what is not?

You have several options for capturing the XML correctly:
  • PHP server file file_get_contents () / cURL

    → The file can now be AJAXed on your page as you are on the same domain.

    → This server side request can also be part of this page, that is: When the page is loaded, PHP / Whatever sounds like a variable in JavaScript or in a hidden element.

  • Modified AJAX request

    → Modified AJAX request that will work with cross-domain requests. This is useful as the server will not fulfill the request you might want. If so, then I must mention; I have a file named jquery.xdomainajax.js

    that allows cross-domain AJAX requests. I'm looking for a source at the moment, but I figured I'd rush this post so you can look for yourself if you like.

    Edit: select this one .

    Edit2: After some brief and sloppy testing, I can't seem to get it to work using the above jQuery plugin ... so my solution would be to clean it up on the server side.

    Here are some more links:

  • How to load a specific div of an external web page in another web page that is on a different domain
  • Get website titles
  • JQuery ajax domain cross call and permission

FYI: I am using FireFox 12.0



All Articles