function handleResponse() {
  // Uncomment these three lines to see what the feed data looks like.
  // var itemsTag = document.getElementById('items');
  // itemsTag.textContent = req.responseText;
  // return;

  var doc = req.responseXML;
  if (!doc) {
    // If the XMLHttpRequest object fails to parse the feed we make an attempt
    // ourselves, because sometimes feeds have html/script code appended below a
    // valid feed, which makes the feed invalid as a whole even though it is
    // still parsable.
    var domParser = new DOMParser();
    doc = domParser.parseFromString(req.responseText, "text/xml");
    if (!doc) {
      handleFeedParsingFailed(
          chrome.i18n.getMessage("rss_subscription_not_valid_feed"));
      return;
    }
  }

  // We must find at least one 'entry' or 'item' element before proceeding.
  var entries = doc.getElementsByTagName('entry');
  if (entries.length == 0)
    entries = doc.getElementsByTagName('item');
  if (entries.length == 0) {
    handleFeedParsingFailed(
        chrome.i18n.getMessage("rss_subscription_no_entries"))
    return;
  }

  // Figure out what the title of the whole feed is.
  var title = doc.getElementsByTagName('title')[0];
  if (title)
    setFeedTitle(title.textContent);
  else
    setFeedTitle(unknownName);

  // Embed the iframe.
  var itemsTag = document.getElementById('items');
  // TODO(aa): Add base URL tag
  iframe = createFrame('rss', styleSheet + frameScript);
  itemsTag.appendChild(iframe);
}
// Handles parsing the feed data we got back from XMLHttpRequest.
Handles parsing the feed data we got back from XMLHttpRequest.
Handles parsing the feed data we got back from XMLHttpRequest .
function handleResponse() {
  var doc = req.responseXML;
  if (!doc) {
    var domParser = new DOMParser();
    doc = domParser.parseFromString(req.responseText, "text/xml");
    if (!doc) {
      handleFeedParsingFailed(
          chrome.i18n.getMessage("rss_subscription_not_valid_feed"));
      return;
    }
  }
  var entries = doc.getElementsByTagName('entry');
  if (entries.length == 0)
    entries = doc.getElementsByTagName('item');
  if (entries.length == 0) {
    handleFeedParsingFailed(
        chrome.i18n.getMessage("rss_subscription_no_entries"))
    return;
  }
  var title = doc.getElementsByTagName('title')[0];
  if (title)
    setFeedTitle(title.textContent);
  else
    setFeedTitle(unknownName);
  var itemsTag = document.getElementById('items');
  iframe = createFrame('rss', styleSheet + frameScript);
  itemsTag.appendChild(iframe);
}
function handleResponse ( ) { var doc = req . responseXML ; if ( ! doc ) { var domParser = new DOMParser ( ) ; doc = domParser . parseFromString ( req . responseText , "text/xml" ) ; if ( ! doc ) { handleFeedParsingFailed ( chrome . i18n . getMessage ( "rss_subscription_not_valid_feed" ) ) ; return ; } } var entries = doc . getElementsByTagName ( 'entry' ) ; if ( entries . length == 0 ) entries = doc . getElementsByTagName ( 'item' ) ; if ( entries . length == 0 ) { handleFeedParsingFailed ( chrome . i18n . getMessage ( "rss_subscription_no_entries" ) ) return ; } var title = doc . getElementsByTagName ( 'title' ) [ 0 ] ; if ( title ) setFeedTitle ( title . textContent ) ; else setFeedTitle ( unknownName ) ; var itemsTag = document . getElementById ( 'items' ) ; iframe = createFrame ( 'rss' , styleSheet + frameScript ) ; itemsTag . appendChild ( iframe ) ; }
Handles parsing the feed data we got back from XMLHttpRequest.
Handles parsing the feed data we got back from XMLHttpRequest .
// Uncomment these three lines to see what the feed data looks like. // var itemsTag = document.getElementById('items'); // itemsTag.textContent = req.responseText; // return; // If the XMLHttpRequest object fails to parse the feed we make an attempt // ourselves, because sometimes feeds have html/script code appended below a // valid feed, which makes the feed invalid as a whole even though it is // still parsable. // We must find at least one 'entry' or 'item' element before proceeding. // Figure out what the title of the whole feed is. // Embed the iframe. // TODO(aa): Add base URL tag