-
Annoying problem with XMLList assignment
Hi guys. I'm creating this XMLList everytime someone clicks a button on my page. As you it's assigned to this static "xml.buildings.projekt" - but I'd like to have it as a variable instead (preferably a string) but I don't the syntax for this.
This works, but it's static:
var projektList:XMLList = xml.buildings.projekt;
I'd like to be like this, dynamic that is:
var projektList:XMLList = xml.STRING.projekt;
But that doesn't work, I get this error when I try that:
1067: Implicit coercion of a value of type String to an unrelated type XMLList.
Anyone know how to solve this? Is it simply a matter of me using the wrong damn syntax?
I'd be very thankful if someone could shed me some light on this!
-
you can use array access:
PHP Code:
var projektlist:XMLList = xml["buildings"].projekt;
e.g.,
PHP Code:
var xml:XML = <root>
<buildings>
<item>building 1</item>
<item>building 2</item>
<item>building 3</item>
</buildings>
<somethingelse>
<item>somethingelse 1</item>
<item>somethingelse 2</item>
<item>somethingelse 3</item>
</somethingelse>
</root>
trace(xml["buildings"].item);
-
Originally Posted by moagrius
you can use array access:
PHP Code:
var projektlist:XMLList = xml["buildings"].projekt;
e.g.,
PHP Code:
var xml:XML = <root>
<buildings>
<item>building 1</item>
<item>building 2</item>
<item>building 3</item>
</buildings>
<somethingelse>
<item>somethingelse 1</item>
<item>somethingelse 2</item>
<item>somethingelse 3</item>
</somethingelse>
</root>
trace(xml["buildings"].item);
Thanks moagrius! That solved it perfectly!
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|