e4x / as3: How to access a node with a dash in its name

我的未来我决定 提交于 2019-12-01 01:57:58

Added a working sample using the two syntaxes : http://wonderfl.net/c/hyuG

You can use myXml["my field"] notation to get your field, as your xml have namespace in it you have to specify it, one way to do this is:

var ns:Namespace=new Namespace("http://musicbrainz.org/ns/mmd-1.0#")
trace(myXml.ns::["artist-list"])

another way is to set the default namespace:

var ns:Namespace=new Namespace("http://musicbrainz.org/ns/mmd-1.0#")
default xml namespace=ns
trace(xml["artist-list"])

You can access it with 'child'

xml.child("artist-list")

Will return an XMLList. Not as neat as regular e4x but that's the way it goes..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!