Hi Jens,
What I basically want is to transform the xml structure into an object
structure.
xml:
<map id="gemRegioIndeling">
<subTitle></subTitle>
<classes>
<class1>
<areaColor>0xEBDBAA</areaColor>
<keyText><![CDATA[Noord-Nederland]]></keyText>
<value>RA01</value>
</class1>
<class2>
<areaColor>0xEBDBAA</areaColor>
<keyText><![CDATA[Noord-Nederland]]></keyText>
<value>RA01</value>
</class2>
<layers>
<gemeenteNaam>
<visible>false</visible>
<title>
<nl><![CDATA[gemeentenamen]]></nl>
</title>
</gemeenteNaam>
</layers>
</map>
flash object:
map
map.classes
map.classes,class1
map.classes,class1.areaColor
map.classes,class1.value
...
map.classes,class2
map.classes,class2.areaColor
map.classes,class2.value
...
...
...
map.layers
...
...
...
Things seem to work, but I want to traverse the properties tree of the flash
object and can't get that part working.
Thanks,
Willem van den Goorbergh
On 16 feb 2011, at 13:10, Jens Struwe wrote:
> Having an example XML could be pretty useful.
>
> And, actually, I don't understand the problem. What should be the output?
> Please hand over all necessary info required to be able to help you.
>
> Am 16.02.2011 12:43, schrieb Geografiek:
>> Hi list,
>> I posted this question a week ago on flash tiger, but never got an answer.
>> So I try my luck here.
>>
>> I create an object and dynamically assign properties to it, values from
>> xml-nodes.
>> If an xml-node has child nodes the property assigned is an object and the
>> values of the child nodes are assigned as properties to that object:
>>
>> private function createProperties(node:XML, container:*):void {
>> for each (var childNode:XML in node.*) {
>> if(childNode.children().length() == 0) {
>> container[childNode.localName()] = null;
>> } else if(childNode.children().length() == 1) {
>> container[childNode.localName()] = childNode.*;
>> } else {
>> container[childNode.localName()] = new Object();
>> createProperties(childNode, container[childNode.localName()]);
>> }
>> }
>> }
>>
>> Now I want to trace what properties are created with the following function:
>> private function traceProperties(object:Object):void {
>> for (var prop:* in object) {
>> trace(prop + " is: " + object[prop]);
>> traceProperties(prop);
>> }
>> if(object.hasOwnProperty("layers")) {
>> trace("this.layers.gemeenteNaam.title is: " +
>> this.layers.gemeenteNaam.title);
>> trace("this.classes.class1.keyText is: " +
>> this.classes.class1.keyText);
>> }
>> }
>>
>> This traces:
>> source is: null
>> note is: null
>> subTitle is: null
>> copyright is: Geografiek, 2011
>> mapType is: chorochromaat
>> classes is: [object Object]
>> key is: [object Object]
>> layers is: [object Object]
>> this.layers.gemeenteNaam.title is: gemeentenamen
>> this.classes.class1.keyText is: Noord-Nederland
>>
>>> From this I gather that all properties are actually created on their
>>> desired level (last 2 traced lines).
>> But the function traceProperties() does not automatically catch all
>> properties. At least not the properies inside the objects
>> How do I check if an object has properties at all and how do I trace them?
>> TIA
>> Willem van den Goorbergh
>>
>> =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
>> Geografiek is a Dutch, Utrecht-based map and chart design company.
>> Willem van den Goorbergh can be contacted by telephone: (+31)30-2719512 or
>> cell phone: (+31)6-26372378
>> or by fax: (+31)302719687
>> snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
>> Visit our website at: www.geografiek.nl
>> twitter: @wvdgoorbergh
>> =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
>>
>>
>>
>>
>>
>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31)30-2719512 or cell
phone: (+31)6-26372378
or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: www.geografiek.nl
twitter: @wvdgoorbergh
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders