문제

I'm trying to get data from a namespaced xml file in a flex app. There is a root namespace (xmlns="blah") and another namespace (xmlns:i="blah"), and I'm able to access most tags using the following:

var ns:Namespace = doc.namespace();
var result:XMLList = doc.ns::element;

However, there are several tags that are subject to change in the application, and i'd like to not hardcode them, possibly using the elements method:

var result:XMLList = doc.elements(configuredField);

Is there a way to get elements with namespaces using the elements method, or a similar way to get XML elements in flex using a parameter?

도움이 되었습니까?

해결책

If I understand you, you can get nodes by using dynamic properties ([ ] notation).

var x:XML=
<root xmlns:i="testNS">
    <elem1>
        hhh
    </elem1>
    <i:elem2>
        123123
    </i:elem2>
</root>;
var elemName:String="elem2";
var ns:Namespace=x.namespace("i");
var tags:*=x.ns::[elemName]; //will contain all "elem2" tags in "i" namespace
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top