【问题标题】:X++ Append Text to StringX++ 将文本附加到字符串
【发布时间】:2014-11-12 15:57:13
【问题描述】:

我目前有一个方法可以根据正在加载的 XML 文件中的标记将两个字符串附加在一起。为了稍后解析的原因,我还想在这两个字符串之间添加一个唯一键。以下是它现在的工作方式以及我希望它做什么的示例。

-CURRENT: strValue~&elem.text()~& 
-GOAL: strValue~&elem.text()

// If the tag is "Tag" or "Building append its text to strValue (part of item name)
        elem = elemTag.selectSingleNode("ofda:Type",nsmgr);

        if(elem && (elem.text() == "Tag" || elem.text() == "Building"))
        {
            elem = elemTag.selectSingleNode("ofda:Value",nsmgr);
            if(elem)
            {
                strValue += elem.text() + "~&";
            }
        }

【问题讨论】:

  • 你试过strValue += elem.text();吗?
  • strValue += elem.text() 可以将字符串附加在一起,但不会在两个字符串之间添加唯一键。
  • 然后将 uniqe 值放在两者之间(guid 或其他)。
  • 尝试将键放在 "strValue + "~&" += elem.text() ;" 之间但这会引发语法错误。

标签: axapta x++


【解决方案1】:

strValue += strValue ? "~&" + elem.text() : elem.text();?

【讨论】:

  • 导致“strValue elem.text()”中间没有任何键。
  • 在什么和什么之间?如果strValue不为空,strValue和elem.text()之间肯定会有"~&"
  • "strValue += strValue ? "~&" + elem.text() : elem.text();"使用 this 连接两个字符串,但没有将 ~& 键放在两个字符串之间。
猜你喜欢
  • 2014-02-25
  • 1970-01-01
  • 1970-01-01
  • 2014-11-18
  • 1970-01-01
  • 2014-04-15
  • 2023-01-11
  • 2016-08-06
  • 1970-01-01
相关资源
最近更新 更多