I have an XML page like below from which i want to extract data:
我有一个像下面的XML页面,我想从中提取数据:
<IMODocHeader>
<DocTitle>Generators Output and Capability Report</DocTitle>
<DocRevision>3</DocRevision>
<DocConfidentiality>
<DocConfClass>PUB</DocConfClass>
</DocConfidentiality>
<CreatedAt>2013-09-28T06:32:41</CreatedAt>
</IMODocHeader>
<IMODocBody>
<Date>2013-09-28</Date>
<Generators>
<Generator>
<GeneratorName>BRUCEA-G1</GeneratorName>
<FuelType>NUCLEAR</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>725</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>724</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>721</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>724</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>722</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>722</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>725</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>724</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>721</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>724</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>722</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>722</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>DARLINGTON-G2</GeneratorName>
<FuelType>NUCLEAR</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>0</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>DARLINGTON-G3</GeneratorName>
<FuelType>NUCLEAR</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>852</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>854</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>855</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>854</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>855</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>854</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>855</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>855</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>855</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>855</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>855</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>855</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>DARLINGTON-G4</GeneratorName>
<FuelType>NUCLEAR</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>844</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>845</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>849</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>850</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>851</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>850</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>855</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>855</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>855</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>855</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>855</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>855</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>PICKERINGA-G1</GeneratorName>
<FuelType>NUCLEAR</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>0</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>PICKERINGA-G4</GeneratorName>
<FuelType>NUCLEAR</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>510</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>510</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>508</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>509</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>510</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>510</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>510</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>510</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>510</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>510</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>510</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>510</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>PICKERINGB-G5</GeneratorName>
<FuelType>NUCLEAR</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>491</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>492</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>492</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>491</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>491</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>491</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>491</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>492</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>492</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>491</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>491</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>491</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>PICKERINGB-G6</GeneratorName>
<FuelType>NUCLEAR</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>0</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>0</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>0</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>PICKERINGB-G7</GeneratorName>
<FuelType>NUCLEAR</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>499</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>499</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>499</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>499</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>499</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>499</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>505</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>505</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>505</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>505</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>505</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>505</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>PICKERINGB-G8</GeneratorName>
<FuelType>NUCLEAR</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>485</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>485</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>483</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>485</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>485</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>485</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>485</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>485</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>483</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>485</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>485</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>485</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<Generator>
<GeneratorName>AMARANTH</GeneratorName>
<FuelType>WIND</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>34</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>45</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>55</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>53</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>53</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>51</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>34</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>45</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>55</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>53</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>53</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>51</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>GOSFIELDWGS</GeneratorName>
<FuelType>WIND</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>9</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>8</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>11</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>11</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>7</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>3</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>9</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>8</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>11</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>11</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>7</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>4</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>GREENWICH</GeneratorName>
<FuelType>WIND</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>85</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>91</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>49</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>79</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>50</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>53</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>85</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>91</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>73</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>79</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>53</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>55</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>KINGSBRIDGE</GeneratorName>
<FuelType>WIND</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>19</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>25</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>24</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>24</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>24</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>26</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>19</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>25</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>24</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>24</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>24</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>26</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>PAROCHES</GeneratorName>
<FuelType>WIND</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>11</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>13</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>13</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>13</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>9</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>5</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>11</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>13</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>13</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>13</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>10</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>6</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>PORT BURWELL</GeneratorName>
<FuelType>WIND</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>27</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>26</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>21</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>18</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>16</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>12</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>27</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>26</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>22</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>18</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>16</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>12</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>PORTALMA-T1</GeneratorName>
<FuelType>WIND</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>47</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>45</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>37</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>24</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>8</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>5</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>47</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>45</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>37</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>26</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>11</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>5</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>PORTALMA-T3</GeneratorName>
<FuelType>WIND</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>40</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>33</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>28</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>20</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>8</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>5</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>40</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>33</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>29</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>21</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>10</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>5</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>PRINCEFARM</GeneratorName>
<FuelType>WIND</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>141</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>130</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>122</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>125</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>109</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>104</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>141</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>130</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>122</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>125</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>110</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>104</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>RIPLEY SOUTH</GeneratorName>
<FuelType>WIND</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>19</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>21</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>19</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>22</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>40</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>40</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>19</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>21</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>19</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>22</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>40</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>40</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>SPENCE</GeneratorName>
<FuelType>WIND</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>18</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>19</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>12</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>13</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>5</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>3</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>18</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>19</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>13</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>13</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>6</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>3</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>SUMMERHAVEN</GeneratorName>
<FuelType>WIND</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>23</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>13</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>12</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>10</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>19</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>10</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>23</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>13</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>12</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>10</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>19</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>10</EnergyMW>
</Capability>
</Capabilities>
</Generator>
<Generator>
<GeneratorName>UNDERWOOD</GeneratorName>
<FuelType>WIND</FuelType>
<Outputs>
<Output>
<Hour>1</Hour>
<EnergyMW>90</EnergyMW>
</Output>
<Output>
<Hour>2</Hour>
<EnergyMW>96</EnergyMW>
</Output>
<Output>
<Hour>3</Hour>
<EnergyMW>54</EnergyMW>
</Output>
<Output>
<Hour>4</Hour>
<EnergyMW>91</EnergyMW>
</Output>
<Output>
<Hour>5</Hour>
<EnergyMW>63</EnergyMW>
</Output>
<Output>
<Hour>6</Hour>
<EnergyMW>90</EnergyMW>
</Output>
</Outputs>
<Capabilities>
<Capability>
<Hour>1</Hour>
<EnergyMW>90</EnergyMW>
</Capability>
<Capability>
<Hour>2</Hour>
<EnergyMW>96</EnergyMW>
</Capability>
<Capability>
<Hour>3</Hour>
<EnergyMW>57</EnergyMW>
</Capability>
<Capability>
<Hour>4</Hour>
<EnergyMW>93</EnergyMW>
</Capability>
<Capability>
<Hour>5</Hour>
<EnergyMW>64</EnergyMW>
</Capability>
<Capability>
<Hour>6</Hour>
<EnergyMW>93</EnergyMW>
</Capability>
</Capabilities>
</Generator>
</Generators>
</IMODocBody>
</IMODocument>
From the above i need to extract all the items of fuel type "Nuclear" and compare if there is change in the "Output" or "Capability" value compared to previous hour.
从上面我需要提取燃料类型“核”的所有项目,并比较“输出”或“能力”值与前一小时相比是否有变化。
I need to extract all data using regular expression as per the strict instruction.
我需要按照严格的指令使用正则表达式提取所有数据。
Using the regex <Hour[^>]*?>(?<Value1>.*?)</Hour>
使用正则表达式
from group "Value" i can get the value of hour and it gives output as 1,2,3,4,5,6,1,2,3,4,5,6 and so on for each generator name but since no of hour is common to all i need that i get it only once that is i should get 1,2,3,4,5,6 only once
从组“值”我可以获得小时的值,它为每个生成器名称输出1,2,3,4,5,6,1,2,3,4,5,6等等但是因为没有小时是所有我需要的共同点我只得到它一次,我应该得到1,2,3,4,5,6只一次
Please help me with this.
请帮我解决一下这个。
2 个解决方案
#1
2
No,you don't use regex to parse XML..Not even if it's a strict instruction to use it.. Seriously who's that!
不,你不使用正则表达式解析XML ..即使它是一个严格的指令使用它。严重的是谁!
XDocument doc=XDocument.Load(PATH);
var generatorsList=
doc.Descendants("Generator")
.Where(x=>x.Element("FuelType").Value=="NUCLEAR")
.Select(y=>new
{
GeneratorName=y.Element("GeneratorName").Value,
OutputHours=y.Element("Outputs").Descendants("Hour").Select(h=>int.Parse(h.Value)).ToList(),
CapabilityHours=y.Element("Capabilities").Descendants("Hour").Select(h=>int.Parse(h.Value)).ToList()
});
Now you can iterate over generatorsList
现在您可以遍历generatorsList
foreach(var generator in generatorsList)
{
generator.GeneratorName;
foreach(int hour in generator.OutputHours);
foreach(int hour in generator.CapabilityHours);
}
#2
-1
I got the solution for my query you can achieve it with the help of regex. In order to get the value of EnergyMW under capability tag i came up with following regex:
(<Capability>[^<]+?).+?(<EnergyMW>(?<Value>.*?)<\/EnergyMW>\n)(</Capability>)
using this expression with RegexOptions.Singleline the target is achieved.
#1
2
No,you don't use regex to parse XML..Not even if it's a strict instruction to use it.. Seriously who's that!
不,你不使用正则表达式解析XML ..即使它是一个严格的指令使用它。严重的是谁!
XDocument doc=XDocument.Load(PATH);
var generatorsList=
doc.Descendants("Generator")
.Where(x=>x.Element("FuelType").Value=="NUCLEAR")
.Select(y=>new
{
GeneratorName=y.Element("GeneratorName").Value,
OutputHours=y.Element("Outputs").Descendants("Hour").Select(h=>int.Parse(h.Value)).ToList(),
CapabilityHours=y.Element("Capabilities").Descendants("Hour").Select(h=>int.Parse(h.Value)).ToList()
});
Now you can iterate over generatorsList
现在您可以遍历generatorsList
foreach(var generator in generatorsList)
{
generator.GeneratorName;
foreach(int hour in generator.OutputHours);
foreach(int hour in generator.CapabilityHours);
}
#2
-1
I got the solution for my query you can achieve it with the help of regex. In order to get the value of EnergyMW under capability tag i came up with following regex:
(<Capability>[^<]+?).+?(<EnergyMW>(?<Value>.*?)<\/EnergyMW>\n)(</Capability>)
using this expression with RegexOptions.Singleline the target is achieved.