想看看一些有趣的事情?
Wanna see something interesting?
var xml:XML = XML(<feed><entry /><entry /><entry /></feed>);
trace(xml.entry.length()) // returns 3
是有道理的,对不对?现在,让我们来添加这个属性...
Makes sense, right? Now let's add this attribute...
var xml:XML = XML(<feed xmlns="http://www.w3.org/2005/Atom"><entry /><entry /><entry /></feed>);
trace(xml.entry.length()) // returns 0
嗯,这不可能是正确的。让我们尝试用一个不同的属性。
Well that can't be right. Let's try it with a different attribute.
var xml:XML = XML(<feed test="okay"><entry /><entry /><entry /></feed>);
trace(xml.entry.length()) // returns 3
任何人都知道什么原因呢?我用原子作为一个例子,但在根节点上的任何'的xmlns'属性似乎有这样的效果。返回的值是直线上升虚假的 - 有显然还是3'入门'的孩子及其家长拥有
Anyone know what would cause this? I used atom as an example, but any 'xmlns' attribute on the root node seems to have this effect. The value returned is straight up false - there are obviously still 3 'entry' child nodes regardless of the attributes their parents possess.
下面是可能的解决方法:
Here are possible workarounds:
var xml:XML = XML(<feed xmlns="http://www.w3.org/2005/Atom"><entry /><entry /><entry /></feed>) ;
trace(xml.entry.length()) ;
// output: 0
var ATOM:Namespace = new Namespace( "http://www.w3.org/2005/Atom" );
trace(xml.ATOM::entry.length()) ;
// output: 3
default xml namespace = ATOM;
trace(xml.entry.length()) ;
// output: 3
更新
LiveDocs.Adobe.Com
上一篇:从引发Event.COMPLETE如何获得相关的URLRequest通过的URLLoader发射如何获得、COMPLETE、Event、URLRequest
下一篇:如何实现对Flash内容上面的html内容,而无需使用&QUOT;透明&QUOT; wmode参数或如何使用时,优化帧率的&QUOT;透明&QUOT; wmode参数的Flash对象吗?透明、参数、内