Selection de noeuds d'un XML avec un combobox ?
Bonjour,
Voilà, j'aimerais savoir si il est possible, à partir d'une combobox, de sélectionner un nœud d'un XML ?
Je m'explique, je suis en train de créer un petit programme, indiquant par région, le budget et les revenus de chaque région, 2 colonnes permettent la comparaison.
Maintenant j'aimerais pouvoir changer de nœud ( années, mois ) avec une combobox, et changerais le XML en live
voici mon XML :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
| <?xml version="1.0" encoding="utf-8"?>
<years>
<year name="2007">
<month name="January">
<region id="11">
<orderEntry>250000</orderEntry>
<orderEntryBudget>230000</orderEntryBudget>
</region>
<region id="21">
<orderEntry>170000</orderEntry>
<orderEntryBudget>180000</orderEntryBudget>
</region>
<region id="31">
<orderEntry>275000</orderEntry>
<orderEntryBudget>230000</orderEntryBudget>
</region>
<region id="41">
<orderEntry>195000</orderEntry>
<orderEntryBudget>200000</orderEntryBudget>
</region>
</month>
<month name="February">
<region id="11">
<orderEntry>220000</orderEntry>
<orderEntryBudget>260000</orderEntryBudget>
</region>
<region id="21">
<orderEntry>210000</orderEntry>
<orderEntryBudget>140000</orderEntryBudget>
</region>
<region id="31">
<orderEntry>245000</orderEntry>
<orderEntryBudget>260000</orderEntryBudget>
</region>
<region id="41">
<orderEntry>225000</orderEntry>
<orderEntryBudget>200000</orderEntryBudget>
</region>
</month>
<month name="March">
<region id="11">
<orderEntry>220000</orderEntry>
<orderEntryBudget>230000</orderEntryBudget>
</region>
<region id="21">
<orderEntry>190000</orderEntry>
<orderEntryBudget>180000</orderEntryBudget>
</region>
<region id="31">
<orderEntry>235000</orderEntry>
<orderEntryBudget>290000</orderEntryBudget>
</region>
<region id="41">
<orderEntry>115000</orderEntry>
<orderEntryBudget>150000</orderEntryBudget>
</region>
</month>
</year>
<year name="2008">
<month name="January">
<region id="11">
<orderEntry>270000</orderEntry>
<orderEntryBudget>210000</orderEntryBudget>
</region>
<region id="21">
<orderEntry>140000</orderEntry>
<orderEntryBudget>130000</orderEntryBudget>
</region>
<region id="31">
<orderEntry>275000</orderEntry>
<orderEntryBudget>280000</orderEntryBudget>
</region>
<region id="41">
<orderEntry>155000</orderEntry>
<orderEntryBudget>260000</orderEntryBudget>
</region>
</month>
<month name="February">
<region id="11">
<orderEntry>260000</orderEntry>
<orderEntryBudget>220000</orderEntryBudget>
</region>
<region id="21">
<orderEntry>270000</orderEntry>
<orderEntryBudget>240000</orderEntryBudget>
</region>
<region id="31">
<orderEntry>275000</orderEntry>
<orderEntryBudget>220000</orderEntryBudget>
</region>
<region id="41">
<orderEntry>225000</orderEntry>
<orderEntryBudget>260000</orderEntryBudget>
</region>
</month>
<month name="March">
<region id="11">
<orderEntry>260000</orderEntry>
<orderEntryBudget>280000</orderEntryBudget>
</region>
<region id="21">
<orderEntry>130000</orderEntry>
<orderEntryBudget>180000</orderEntryBudget>
</region>
<region id="31">
<orderEntry>285000</orderEntry>
<orderEntryBudget>260000</orderEntryBudget>
</region>
<region id="41">
<orderEntry>165000</orderEntry>
<orderEntryBudget>150000</orderEntryBudget>
</region>
</month>
</year>
<year name="2009">
<month name="January">
<region id="11">
<orderEntry>230000</orderEntry>
<orderEntryBudget>260000</orderEntryBudget>
</region>
<region id="21">
<orderEntry>150000</orderEntry>
<orderEntryBudget>170000</orderEntryBudget>
</region>
<region id="31">
<orderEntry>225000</orderEntry>
<orderEntryBudget>250000</orderEntryBudget>
</region>
<region id="41">
<orderEntry>175000</orderEntry>
<orderEntryBudget>240000</orderEntryBudget>
</region>
</month>
<month name="February">
<region id="11">
<orderEntry>220000</orderEntry>
<orderEntryBudget>270000</orderEntryBudget>
</region>
<region id="21">
<orderEntry>250000</orderEntry>
<orderEntryBudget>240000</orderEntryBudget>
</region>
<region id="31">
<orderEntry>265000</orderEntry>
<orderEntryBudget>290000</orderEntryBudget>
</region>
<region id="41">
<orderEntry>265000</orderEntry>
<orderEntryBudget>280000</orderEntryBudget>
</region>
</month>
<month name="March">
<region id="11">
<orderEntry>280000</orderEntry>
<orderEntryBudget>250000</orderEntryBudget>
</region>
<region id="21">
<orderEntry>140000</orderEntry>
<orderEntryBudget>150000</orderEntryBudget>
</region>
<region id="31">
<orderEntry>235000</orderEntry>
<orderEntryBudget>270000</orderEntryBudget>
</region>
<region id="41">
<orderEntry>135000</orderEntry>
<orderEntryBudget>120000</orderEntryBudget>
</region>
</month>
</year>
</years> |
le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| <?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="dataRequest.send()">
<mx:HTTPService id="dataRequest" url="C:\testyear.xml"
result="dataRequestResultHandler(event);"
fault="dataRequestFaultHandler(event);" />
<mx:Script>
<![CDATA[
import flash.trace.Trace;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
[Bindable]
private var stats:ArrayCollection;
[Bindable]
private var stats2:ArrayCollection;
[Bindable]
private var stats3:ArrayCollection;
[Bindable]
private var stats4:ArrayCollection;
private function dataRequestResultHandler(event:ResultEvent):void {
stats = event.result.years.year[0].month[0].region;
stats2 = event.result.years.year[0].month[2].region;
stats3 = event.result.years.year;
stats4 = event.result.years.year[0].month;
trace(stats)
}
private function dataRequestFaultHandler(event:FaultEvent):void {
Alert.show(event.fault.message);
}
]]>
</mx:Script>
<mx:ColumnChart x="209" y="201" id="columnchart" dataProvider="{stats}" width="675" showDataTips="true">
<mx:series>
<mx:ColumnSeries displayName="Budget" yField="orderEntryBudget" />
<mx:ColumnSeries displayName="Revenus" yField="orderEntry" />
</mx:series>
<mx:horizontalAxis>
<mx:CategoryAxis dataProvider="{stats2}" categoryField="id"/>
</mx:horizontalAxis>
</mx:ColumnChart>
<mx:Legend dataProvider="{columnchart}" x="80" y="89"/>
<mx:ComboBox x="334" y="120" dataProvider="{stats3}" labelField="name" prompt="Choisissez l'année"/>
<mx:ComboBox x="537" y="120" dataProvider="{stats4}" labelField="name" prompt="Choississez le mois"/>
</mx:WindowedApplication> |
Pour le moment, j'ai compris comment afficher ce que je voulais, mais je ne trouve pas de tutoriel ou de documentation pour effectuer correctement la selection des noeud :(
Merci d'avance pour votre aide !