Skip to content
Advertisement

Creating a Function to Process an RSS Feed in Google Sheets

I am trying to create a function that I can import into Google Sheets to view the latest bills from this website. A problem that I am having is that when I create only one variable to be appended to the Google Sheet this code will work and append the first cell. But when I create multiple variables using the same logic, but for different parts of the xml file that this link brings you to, it gives me this error even when I create completely different variables for the original document and root: TypeError: Cannot read property ‘getValue’ of null. Would anyone be able to show me what I am doing wrong so that I can at least get it so that all of these items can be appended to the Google Sheet through solving for this error and show me a way to do a loop to get all these items?

JavaScript

Advertisement

Answer

I believe your goal as follows.

  • You want to retrieve the values of legislativeSession, title, category, pubDate, description, link in order using Google Apps Script.
  • You want to put the retrieved values to Google Spreadsheet.

Modification points:

  • In the case of derss:legislativeSession, derss is the name space. So in this case, it is required to use the name space.
  • When I saw your XML data, there are many item tags. But in your script, 1st item is trying to be retrieved.
  • When the values from all items are retrieved, when appendRow is used in a loop, the process cost will become high.

When above points are reflected to your script, it becomes as follows.

Modified script:

JavaScript
  • In this modified script, it supposes that the active sheet is the 1st sheet. If your actual situation is different, please modify above script.

References:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement