访问名称中具有特殊字符的 E4X 节点而不破坏 Flex 中的绑定链
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
的
类在这种情况下适合您吗?我现在无法检查它,但child()
函数XMLchild()
返回一个XMLList
并且应该适用于绑定。或者,您是否不能仅替换所有“有问题的”节点名称(将原始名称存储在字典中,替换名称作为键),然后进行绑定,从而完全避免该问题?
Would the
child()
function of theXML
class work for you in that situation? I can't check it right now, butchild()
returns anXMLList
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?