E4X 条件调用仅返回 1 个匹配项而不返回任何内容?
好的,这是我的代码:
var xml:XML =
<xml>
<typeA amount1="500" amount2="300" amount3="250" date="2008-02-17"/>
<typeA amount1="500" amount2="300" amount3="250" date="2008-02-16"/>
<typeA amount1="500" amount2="300" amount3="250" date="2008-02-17"/>
<typeB amount1="500" amount2="300" amount3="250" date="2008-02-18"/>
<typeB amount1="500" amount2="300" amount3="250" date="2008-02-19"/>
<typeC amount1="500" amount2="300" amount3="250" date="2008-02-20"/>
<typeC amount1="500" amount2="300" amount3="250" date="2008-02-21"/>
<typeC amount1="500" amount2="300" amount3="250" date="2008-02-20"/>
</xml>;
trace(xml.typeA.(@date == "2008-02-16")); // no results
trace(xml.typeA.(@date == "2008-02-17")); // finds both
trace(xml.typeC.(@date == "2008-02-20")); // finds both
trace(xml.typeC.(@date == "2008-02-21")); // no results
似乎只有在出现次数超过 1 次时才能找到它。
难道我做错了什么?
ok here is my code:
var xml:XML =
<xml>
<typeA amount1="500" amount2="300" amount3="250" date="2008-02-17"/>
<typeA amount1="500" amount2="300" amount3="250" date="2008-02-16"/>
<typeA amount1="500" amount2="300" amount3="250" date="2008-02-17"/>
<typeB amount1="500" amount2="300" amount3="250" date="2008-02-18"/>
<typeB amount1="500" amount2="300" amount3="250" date="2008-02-19"/>
<typeC amount1="500" amount2="300" amount3="250" date="2008-02-20"/>
<typeC amount1="500" amount2="300" amount3="250" date="2008-02-21"/>
<typeC amount1="500" amount2="300" amount3="250" date="2008-02-20"/>
</xml>;
trace(xml.typeA.(@date == "2008-02-16")); // no results
trace(xml.typeA.(@date == "2008-02-17")); // finds both
trace(xml.typeC.(@date == "2008-02-20")); // finds both
trace(xml.typeC.(@date == "2008-02-21")); // no results
It seems like it is only finding it if there is more then 1 occurance.
Am I doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上它找到了它,但因为它只是一项,所以它以 XML(而不是 XMList)的形式跟踪它。
节点为空时,它只会跟踪一个空字符串。
试试这个:
当您调试 XML 时,您最好使用
toXMLString
方法。Actually it finds it but because it's only one item it traces it as an XML (instead of XMList).
The node being empty it will just trace an empty string.
Try this :
When you are debugging XML you'd better use the
toXMLString
method.