访问名称中具有特殊字符的 E4X 节点而不破坏 Flex 中的绑定链

发布于 2024-08-29 03:09:52 字数 388 浏览 10 评论 0原文

我正在使用 E4X 绑定 Flex 3 中 xml 中的一些值。

当 xml 标记(或属性)名称中包含特殊字符时,会出现问题:

var xml:XML = <tag>
    <special-name att="val" />
</tag>

无法使用 xml 内容 special-name 访问xml.special-name.@att 因为它被解释为减法,另一方面使用方括号表示法 xml['special-name'].@att 会破坏绑定链。

有没有一种优雅的方法来解决这个问题(比如特殊的语言语法),而无需编写自定义绑定设置器和侦听器?

I am using E4X to bind some values from xml in flex 3.

There is a problem when xml tag's (or attribute's) name has special character in it: having xml content

var xml:XML = <tag>
    <special-name att="val" />
</tag>

special-name could not be accessed using xml.special-name.@att because it is interpreted as subtraction, on the other hand using square bracket notation xml['special-name'].@att breaks binding chain.

Is there an elegant way to solve this (like special language syntax) without writing custom binding setters and listeners?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光与爱终年不遇 2024-09-05 03:09:52

child() 函数XML 类在这种情况下适合您吗?我现在无法检查它,但 child() 返回一个 XMLList 并且应该适用于绑定。

或者,您是否不能仅替换所有“有问题的”节点名称(将原始名称存储在字典中,替换名称作为键),然后进行绑定,从而完全避免该问题?

Would the child() function of the XML class work for you in that situation? I can't check it right now, but child() returns an XMLList and that should work for binding.

Alternatively, couldn't you just replace all "problematic" node names (storing the original names in a Dictionary with the replacement names being the keys) and then do the binding, simply avoiding the issue altogether?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文