Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 为什么谷歌应用程序脚本XmlElement字符串比较计算不正确?_Google Apps Script - Fatal编程技术网

Google apps script 为什么谷歌应用程序脚本XmlElement字符串比较计算不正确?

Google apps script 为什么谷歌应用程序脚本XmlElement字符串比较计算不正确?,google-apps-script,Google Apps Script,我有一个XML元素。我正在对它包含的文本执行字符串比较。所有人都认为,这种比较应该通过。直到最近,这段代码还是成功的。然而,它现在正在失败 // caller .... processRow('my title', atag); ... function processRow(title, rowtag) { // rowtag.getText() returns the string 'my title' if (rowtag.getText() == title) {

我有一个XML元素。我正在对它包含的文本执行字符串比较。所有人都认为,这种比较应该通过。直到最近,这段代码还是成功的。然而,它现在正在失败

// caller ....
  processRow('my title', atag);
  ...

function processRow(title, rowtag) {
  // rowtag.getText() returns the string 'my title'

  if (rowtag.getText() == title) {
    // ... this section is never entered

在调试模式下,我看到两个相同的字符串对象被比较。我做错了什么吗?

结果是xml内容中存在额外的空间。差异未反映在可变检查窗口中;但是,日志记录程序日志正确地显示了字符串。

请帮自己一个忙,并将if a
logger.log(“rowtag.getText()=”+rowtag.getText()+”,title=“+title”)放在日志的正前方并检查日志中的内容…这很有帮助。事实证明,xml文本中还有一个额外的空间。由于某些原因,可变检查窗中没有额外的空间。