So, I would like to know how to parse an xml document with JavaScript.
I've got it working in php (view below)
<?php
$xmlGmailFeed = file_get_contents("https://gmail_username:[email protected]/mail/feed/atom/");
$unreadMessages = $xmlGmailFeed->fullcount;
echo $unreadMessages;
?>
But the only thing with this, is that it's running using the server's IP address and doesnt let users login to their gmail. It pops up saying that there was a suspicious login attempt on their account. So what Id like to know is how I would be able to do the same thing, but run it from the hosts computer. I was thinking javascript to do it? But please let me know if theres a better way!
Edit:
Heres the code that im using..
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script>
$.ajax({
type: "GET",
url: "https://mail.google.com/mail/feed/atom.",
dataType: "xml",
crossDomain: true,
success: parseXml
});
function parseXml(xml)
{
var results = $(xml).find("fullcount").text();
alert(results);
}
</script>
Here's a screen shot of my problem:
http://cbog.co.nr/SC.php?img=Admin/AE0BCBAA4F532BC69A932E5DDD8F14F2
and you can see for yourself, live at: