Wed Aug 22, 2012 1:50 pm
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Title here (Feed Title)</title>
<subtitle>If there a subtitle</subtitle>
<link href="http://codemiles.com/feed/" rel="self" />
<link href="http://codemiles.com/" />
<id>urn:uuid:5ce14e53-a349-1455-c433-4305315cccc6</id>
<updated>2012-11-11T18:10:01Z</updated>
<entry>
<title>Parsing ATOM Feeds</title>
<link href="http://codemiles.com/2012/11/11/atom03" />
<link rel="alternate" type="text/html" href="http://codemiles.com/2012/11/11/atom03.html"/>
<link rel="edit" href="http://codemiles.com/2012/11/11/atom03/edit"/>
<id>urn:uuid:14444ccc-13ec-3cc2-142c-13ac4cec5c3c</id>
<updated>2012-11-11T18:10:02Z</updated>
<summary>Some text.</summary>
<author>
<name>msi_333</name>
<email>[email protected]</email>
</author>
</entry>
</feed>
<script type="text/javascript">
dojo.addOnLoad(function() {
var htmlDivID = "contentDiv";
// Parse ATOM feed
dojo.xhrGet({
url: "myFeed.xml",
preventCache: true,
handleAs: "xml",
load: function(xmlDoc, ioArgs){
var i = 0;
var htmlOutputContent = "";
var node = xmlDoc.getElementsByTagName("feed").item(0);
if (node == null) {
console.debug("ERROR: Error in parsing ATOM Feeds XML format.");
return;
}
var NumOfFeedsEntry = node.getElementsByTagName("entry").length;
for (i = 0; i < NumOfFeedsEntry; ++i) {
var entry = node.getElementsByTagName('entry').item(i);
var title = entry.getElementsByTagName('title').item(0).firstChild.data;
var published = entry.getElementsByTagName('published').item(0).firstChild.data;
var summary = entry.getElementsByTagName('summary').item(0).firstChild.data;
var link = entry.getElementsByTagName('link').item(0).getAttribute("href");
htmlOutputContent += '<hr><p><a target="_blank" href="' + link +'">' + title + '</a><br/>' +
'<span class="smaller">' + published + '</span><br/>' +
summary +
'</p>';
}
document.getElementById(htmlDivID).innerHTML = htmlOutputContent;
},
error: function(error, ioArgs){
dojo.byId(htmlDivID).innerHTML = "Error In Loading and Parsing The Atom Feeds";
console.debug("ATOM URL CONTENT PASRING ERROR (DEBUG): ", error, ioArgs);
}
});
});
</script>
<div id="contentDiv"></div>
http://en.wikipedia.org/wiki/Atom_%28standard%29
|
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.