0

我有一个如下所示的 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>

从上面我需要提取燃料类型“核”的所有项目,并比较“输出”或“能力”值与前一小时相比是否发生变化。

我需要按照严格的说明使用正则表达式提取所有数据。

使用正则表达式<Hour[^>]*?>(?<Value1>.*?)</Hour>

从“值”组中,我可以获得小时的值,它为每个生成器名称提供 1、2、3、4、5、6、1、2、3、4、5、6 等输出,但由于没有小时是我所需要的,我只需要一次,也就是说我应该只获得一次 1,2,3,4,5,6

请帮我解决一下这个。

4

2 回答 2

2

不,您不使用正则表达式来解析 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()

   });

现在你可以迭代generatorsList

foreach(var generator in generatorsList)
{
    generator.GeneratorName;
    foreach(int hour in generator.OutputHours);
    foreach(int hour in generator.CapabilityHours);
}
于 2013-09-28T13:25:35.940 回答
-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.
于 2013-10-08T09:55:16.393 回答