Google owned blogging platform providing a free way to manage blogs. It is following atom feed to provide sitemaps to search engines. This blog is also from blogger platform. You can submit this sitemap URL to google web master tools to have better SEO. Ok, now we will see how to generate Atom feed for Blogger blog. Observe below syntax


start-index and max-results will decide the atom feed content
<blog url>/atom.xml?redirect=false&start-index=1&max-results=50
Click on below link to get latest 3 articles feed
Click on below link to get 5th latest article feed

XML Structure

Atom feed gives data in XML format. Find below for format 
<feed ----->
     <category term="---"/>
     <category term="---"/>
     <content ---->

Java Program

Lets move to java program. We need to read atom feed xml nodes to get the required data. The below example is for reading article titles and their tags. Observe below java program. This program reads all articles titles and tags of this blog
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

public class BloggerReader {
    static int FEED_COUNT = 50;
    public static void main(String[] args) {
        try {
            int START_INDEX = 1; 
            while (true) {
                // Atom feed URL
                URL url = new URL(
                                + FEED_COUNT);
                InputStream input = url.openStream();

                // XPATH to get entries
                DocumentBuilderFactory factory = DocumentBuilderFactory
                DocumentBuilder builder = factory.newDocumentBuilder();
                Document doc = builder.parse(input);
                XPathFactory xPathfactory = XPathFactory.newInstance();
                XPath xpath = xPathfactory.newXPath();
                XPathExpression expr = xpath.compile("/feed/entry");

                // Get Nodelist of entries
                NodeList nl = (NodeList) expr.evaluate(doc,

                // iterate Nodelist
                for (int i = 0; i < nl.getLength(); i++) {
                    NodeList nl1 = nl.item(i).getChildNodes();

                    // iterate child nodes
                    for (int j = 0; j < nl1.getLength(); j++) {
                        Node node = nl1.item(j);
                        if (node.getNodeName().equals("title")) {
                            // print title
                        } else if (node.getNodeName().equals("category")) {
                            // print categories
                START_INDEX += FEED_COUNT;
                if(FEED_COUNT > nl.getLength()) {
        } catch (SAXParseException err) {
        } catch (SAXException e) {
        } catch (Throwable t) {


  1. I enjoyed over read your blog post. Your blog have nice information, I got good ideas from this van rental montreal amazing blog. I am always searching like this type blog post. I hope I will see again.



Follow this blog by Email

Popular Posts