Google Sheets: 对实体“Wheel-TW”的引用必须以“;”分隔符结尾

huangapple go评论68阅读模式
英文:

Google Sheets: The reference to entity "Wheel-TW" must end with the ';' delimiter

问题

我正在使用以下脚本在Google Sheets文档的Google Apps部署中构建和更新RSS源数据库,以包含每周发布的所有新项目。

function getURLData() {
  var currentData = [];
  var urltoCheck = [
    "https://agremia.com/feed",
  ];
  for (var i = 0; i < urltoCheck.length; i++){
    var ficiencaData = UrlFetchApp.fetch(urltoCheck[i]);
    var xml = ficiencaData.getContentText();
    let response = XmlService.parse(xml);
    var root = response.getRootElement();
    let channel = root.getChild('channel');
    let items = channel.getChildren('item');
    items.forEach(item => {
      let title = item.getChild('title').getText();
      let pubDateb = item.getChild('pubDate').getText();
      let link = item.getChild('link').getText();
      currentData.push([title,pubDateb,link,urltoCheck[i]]);
    });
  }
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Combinado Medios");
  var currentDataRange = sheet.getRange(sheet.getLastRow() + 1, 1, currentData.length, currentData[0].length);
  currentDataRange.setValues(currentData);
}

我已经使用了一个星期了,一切都很顺利。现在我遇到了以下错误,但我真的不知道该如何修复。

异常: 第 134 行出错:对实体“Wheel-TW”的引用必须以“;”定界符结束。getURLData @ code new.gs:24

这很奇怪,因为根本不存在名为"Wheel-TW"的实体,所以我不明白代码中可能出现的错误。我尝试了一些类似问题中提到的解决方案,但到目前为止都没有奏效。

任何帮助将不胜感激。

英文:

I am using the following script in a Google Apps deployment of a Google Sheets document to build and update a RSS feed database with all the new items that are published every week.

function getURLData() {
 
  var currentData = [];
  var urltoCheck = [
    &quot;https://agremia.com/feed&quot;,
  ];
  for (var i = 0; i &lt; urltoCheck.length; i++){
  var ficiencaData = UrlFetchApp.fetch(urltoCheck[i]);
  var xml = ficiencaData.getContentText()
  let response = XmlService.parse(xml);
  var root = response.getRootElement();
   let channel = root.getChild(&#39;channel&#39;);
  let items = channel.getChildren(&#39;item&#39;);
    items.forEach(item =&gt; {
      let title = item.getChild(&#39;title&#39;).getText();
      let pubDateb = item.getChild(&#39;pubDate&#39;).getText();
      let link = item.getChild(&#39;link&#39;).getText();
      currentData.push([title,pubDateb,link,urltoCheck[i]])
   
  });
};;;
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var sheet = ss.getSheetByName(&quot;Combinado Medios&quot;);
  var currentDataRange = sheet.getRange(sheet.getLastRow() + 1, 1, currentData.length, currentData[0].length);
  currentDataRange.setValues(currentData); 
  
}

I have been using this for a good week and it worked just fine. Now I am getting th following error, which I don't really know how to fix

Exception: Error on line 134: The reference to entity &quot;Wheel-TW&quot; must end with the &#39;;&#39; delimiter. getURLData	@ code new.gs:24 

It's strange because there is no such thing as a Wheel-TW entity, so I don't understand what the error in the code might be. I've tried applying some of the solutions mentioned in similar questions but none have worked so far.

Any help would be much appreciated.

答案1

得分: 1

从您的下面回复中,

> 您可以检查此Google Sheets文档中的代码:docs.google.com/spreadsheets/d/…我所做的只是:1)将工作表重命名为Combinado Medios;2)创建新的Google Apps脚本;3)粘贴代码;4)重命名,授予权限,保存并运行。

当我看到您提供的电子表格时,我注意到包含的脚本与您显示的脚本不同。在您的问题中显示的脚本中,只使用了一个URL。但是,当我测试您的实际脚本时,我注意到您的问题的URL与显示的脚本的URL不同。从这种情况来看,当我测试您的实际脚本时,我可以知道您当前问题的原因。

当您修改显示的脚本时,请按以下方式进行修改。

从:

var xml = ficiencaData.getContentText()

到:

var xml = ficiencaData.getContentText().replace(/&amp;/g, &quot;&amp;amp;&quot;);

当这个修改反映在您的显示脚本中时,它变成了以下内容。

function getURLData() {
  var currentData = [];
  var urltoCheck = [&quot;URL1&quot;, &quot;URL2&quot;,,,&quot;URL14&quot;]; // 请设置您的实际14个URL。
  for (var i = 0; i &lt; urltoCheck.length; i++) {
    var ficiencaData = UrlFetchApp.fetch(urltoCheck[i]);
    var xml = ficiencaData.getContentText().replace(/&amp;/g, &quot;&amp;amp;&quot;);
    let response = XmlService.parse(xml);
    var root = response.getRootElement();
    let channel = root.getChild(&#39;channel&#39;);
    let items = channel.getChildren(&#39;item&#39;);
    items.forEach(item =&gt; {
      let title = item.getChild(&#39;title&#39;).getText();
      let pubDateb = item.getChild(&#39;pubDate&#39;).getText();
      let link = item.getChild(&#39;link&#39;).getText();
      currentData.push([title, pubDateb, link, urltoCheck[i]])
    });
  };
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var sheet = ss.getSheetByName(&quot;Combinado Medios&quot;);
  var currentDataRange = sheet.getRange(sheet.getLastRow() + 1, 1, currentData.length, currentData[0].length);
  currentDataRange.setValues(currentData);
}
  • 当我使用您的14个URL测试这个修改后的脚本时,我确认没有错误。
英文:

From your following reply,

> you may check the code in this Google Sheets document: docs.google.com/spreadsheets/d/… All I did was: 1) rename sheet to Combinado Medios; 2) create new Google Apps script; 3) Paste the code; 4) Rename, give permission, save and run.

When I saw your provided Spreadsheet, I noticed that the including script is different from your showing script. In your showing script in your question, only one URL is used. But, when I tested your actual script, I noticed that the URL of your issue is different from that of your showing script. From this situation, when I tested your actual script, I could know the reason for your current issue.

When your showing script is modified, please modify it as follows.

From:

var xml = ficiencaData.getContentText()

To:

var xml = ficiencaData.getContentText().replace(/&amp;/g, &quot;&amp;amp;&quot;);

When this modification is reflected in your showing script, it becomes as follows.

function getURLData() {
  var currentData = [];
  var urltoCheck = [&quot;URL1&quot;, &quot;URL2&quot;,,,&quot;URL14&quot;]; // Please set your actual 14 URLs.
  for (var i = 0; i &lt; urltoCheck.length; i++) {
    var ficiencaData = UrlFetchApp.fetch(urltoCheck[i]);
    var xml = ficiencaData.getContentText().replace(/&amp;/g, &quot;&amp;amp;&quot;);
    let response = XmlService.parse(xml);
    var root = response.getRootElement();
    let channel = root.getChild(&#39;channel&#39;);
    let items = channel.getChildren(&#39;item&#39;);
    items.forEach(item =&gt; {
      let title = item.getChild(&#39;title&#39;).getText();
      let pubDateb = item.getChild(&#39;pubDate&#39;).getText();
      let link = item.getChild(&#39;link&#39;).getText();
      currentData.push([title, pubDateb, link, urltoCheck[i]])
    });
  };
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var sheet = ss.getSheetByName(&quot;Combinado Medios&quot;);
  var currentDataRange = sheet.getRange(sheet.getLastRow() + 1, 1, currentData.length, currentData[0].length);
  currentDataRange.setValues(currentData);
}
  • When I tested this modified script using your 14 URLs, I confirmed no error.

huangapple
  • 本文由 发表于 2023年6月27日 19:08:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76564246.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定