views:

162

answers:

1

I am trying to parse an ATOM feed and display the relevant parts I need. After doing some searching, I couldn't find a way to do this in Dojo, so I wrote this implementation to get by in the meantime (var xml contains the atom feed):

var names = this.getArray(xml.getElementsByTagName("name"));
var contents = this.getArray(xml.getElementsByTagName("content"));
var emails = this.getArray(xml.getElementsByTagName("email"));
var pubTimes = this.getArray(xml.getElementsByTagName("published"));

getArray: function(data) {
    var theArray = [];
    dojo.forEach(data, function (entry) {
        theArray.push(entry);
    });
    return theArray;
}

These arrays are then used to print out a formatted version of the ATOM feed. I'm new to Javascript and Dojo, and I'm sure there is a better/easier way to parse the XML.

Thanks in advance.

A: 

Have you tried dojox.atom?

peller