Translate

Parse XML RSS Feeds with Google Scripts


Parse XML RSS Feeds with Google Apps Script in Google Sheets

RSS (Really Simple Syndication) is a web feed format used to publish frequently updated information like blog entries, news headlines, or podcasts. If you want to fetch and display RSS feed items automatically inside Google Sheets, Google Apps Script is the perfect tool.

This tutorial shows you step-by-step how to fetch, parse, and display RSS feed items using custom Google Apps Script code in a spreadsheet.


Why Parse RSS Feeds in Google Sheets?

  • Track news headlines from multiple sites in one place

  • Monitor blog updates for content curation

  • Fetch YouTube video titles from RSS feeds

  • Create custom dashboards for clients, research, or marketing teams

Google Sheets makes it easy to organize and filter feed data, while Apps Script gives you automation power without any extra software.


Step-by-Step Guide: Parse RSS XML with Apps Script

Step 1: Open Google Apps Script Editor

  1. Open a new Google Sheet.

  2. Click on Extensions > Apps Script.

  3. Delete the default myFunction().


Step 2: Paste the Script Code

Here's a sample script that parses RSS feed XML and displays titles, links, and dates.

function fetchRSSFeed() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const feedUrl = 'https://www.nasa.gov/rss/dyn/breaking_news.rss'; // Change this to your desired RSS feed URL

  const response = UrlFetchApp.fetch(feedUrl);
  const xml = XmlService.parse(response.getContentText());
  const root = xml.getRootElement();

  // Navigate to the <channel> element
  const channel = root.getChild("channel");
  const items = channel.getChildren("item");

  // Clear previous data
  sheet.clearContents();
  sheet.appendRow(["Title", "Link", "Published Date"]);

  // Loop through RSS items
  items.forEach(function(item) {
    const title = item.getChild("title").getText();
    const link = item.getChild("link").getText();
    const pubDate = item.getChild("pubDate").getText();

    sheet.appendRow([title, link, pubDate]);
  });
}

Step 3: Run the Script

  1. Click the Run ▶ button in the Apps Script editor.

  2. Authorize the script when prompted.

  3. Switch back to your spreadsheet and you'll see the RSS feed items loaded.


Customize It for Your Use Case

Use a Different RSS Feed

Replace the URL in this line:

const feedUrl = 'https://www.nasa.gov/rss/dyn/breaking_news.rss';

with any valid RSS feed like:

  • BBC News: http://feeds.bbci.co.uk/news/rss.xml

  • The Verge: https://www.theverge.com/rss/index.xml

  • YouTube Channel: https://www.youtube.com/feeds/videos.xml?channel_id=CHANNEL_ID

Note: Always verify the feed is accessible and formatted properly.


Parse More Elements (Description, Author, etc.)

You can extract additional elements:

const description = item.getChild("description").getText();
const author = item.getChild("author") ? item.getChild("author").getText() : "";

And include them in your sheet:

sheet.appendRow([title, link, pubDate, description, author]);

Handle Namespaces (for Atom feeds or YouTube)

Some feeds use namespaces, so you need to parse with them like this:

const namespace = XmlService.getNamespace("yt", "http://www.youtube.com/xml/schemas/2015");
const channelId = root.getChild("channel").getChild("channelId", namespace).getText();

Optional: Create a Custom Menu in Google Sheets

Make it user-friendly by adding a custom menu:

function onOpen() {
  const ui = SpreadsheetApp.getUi();
  ui.createMenu("RSS Tools")
    .addItem("Fetch Latest RSS Items", "fetchRSSFeed")
    .addToUi();
}

Now users can click “RSS Tools > Fetch Latest RSS Items” directly from the sheet.


Automate RSS Feed Parsing (Time Trigger)

You can fetch updates every hour or day:

  1. In Apps Script editor, click the Triggers icon (⏰).

  2. Click + Add Trigger.

  3. Choose function: fetchRSSFeed

  4. Select event source: Time-driven

  5. Choose interval (e.g., every hour)

Now your feed updates automatically!


Example Use Cases

  • News Dashboard: Monitor several news outlets on one sheet.

  • Content Research: Track competitors’ blog posts.

  • YouTube Publishing: Monitor latest uploads from a list of channels.

  • Podcast Tracker: List new episodes from your favorite shows.


Common Errors & Fixes

Error Cause Fix
Cannot read property 'getText' of null The XML element is missing Use a conditional check before calling .getText()
Exception: Invalid XML Malformed feed or non-XML URL Verify the RSS feed URL is correct
Nothing shows up Namespace conflict or wrong element name Inspect the raw XML in browser, adjust tag access accordingly

Conclusion

Parsing XML RSS feeds with Google Apps Script is a powerful way to turn a plain spreadsheet into a live content feed dashboard. Whether you’re a content marketer, journalist, analyst, or developer, this method saves time and gives you full control of feed data inside Google Sheets.

With just a few lines of code, you can automate feed parsing, customize your columns, and integrate data from multiple websites — all inside the familiar spreadsheet interface.