title: Parsing XML file using DOM4J
body: <p>I'm having problems parsing XML.</p>
  
  <p>I have the following method:</p>
  
  <pre><code>public void componentsInfoToSimulation(String houseDivision, String equipment) {
          Element root = doc.getRootElement();
          pt.ipp.isep.gecad.masgrip.Simulation.getHouseNamesOfComponents().add(equipment);
  
          for (Iterator i = root.elementIterator("house"); i.hasNext();) {
              Element element = (Element) i.next();
  
              if (element.attributeValue("id").equals(houseDivision)) {
  
                  for (Iterator j = element.elementIterator("" + houseDivision); j.hasNext();) {
                      Element innerElement = (Element) j.next();
  
                      if (innerElement.attributeValue("id").equals(equipment)) {
  
                          for (Iterator k = innerElement.elementIterator("" + equipment); k.hasNext();) {
                              Element innerSubElement = (Element) k.next();
  
                              String op = innerSubElement.getQualifiedName();
                              switch (op) {
                                  case "power":
                                      pt.ipp.isep.gecad.masgrip.Simulation.getHousePowerDosComponents().add(Integer.parseInt(innerSubElement.getTextTrim()));
                                      break;
                                  case "min_power":
                                      pt.ipp.isep.gecad.masgrip.Simulation.getHouseMinPowerComponents().add(Integer.parseInt(innerSubElement.getTextTrim()));
                                      break;
  
                                  case "max_power":
                                      pt.ipp.isep.gecad.masgrip.Simulation.getHouseMaxPowerComponents().add(Integer.parseInt(innerSubElement.getTextTrim()));
                                      break;
  
                                  case "average_usage_hour":
                                      pt.ipp.isep.gecad.masgrip.Simulation.getHouseAverageUsageHoursPerDay().add(Float.parseFloat(innerSubElement.getTextTrim()));
                                      break;
  
                                  case "average_usage_minute":
                                      pt.ipp.isep.gecad.masgrip.Simulation.getHouseAverageUsageMinutesPerDay().add(Float.parseFloat(innerSubElement.getTextTrim()));
                                      break;
  
                                  default:
                                      break;
                              }
                          }
                      }
                  }
              }
          }
          System.out.println("" + pt.ipp.isep.gecad.masgrip.Simulation.getHouseNamesOfComponents());
          System.out.println("" + pt.ipp.isep.gecad.masgrip.Simulation.getHousePowerDosComponents());
          System.out.println("" + pt.ipp.isep.gecad.masgrip.Simulation.getHouseMinPowerComponents());
          System.out.println("" + pt.ipp.isep.gecad.masgrip.Simulation.getHouseMaxPowerComponents());
          System.out.println("" + pt.ipp.isep.gecad.masgrip.Simulation.getHouseAverageUsageHoursPerDay());
          System.out.println("" + pt.ipp.isep.gecad.masgrip.Simulation.getHouseAverageUsageMinutesPerDay());
  
      }
  </code></pre>
  
  <p>And here's a sample of my XML file:</p>
  
  <pre><code>&lt;components&gt;
      &lt;house id="Kitchen"&gt;
          &lt;espresso_machine id="espresso machine"&gt;
              &lt;power&gt;360&lt;/power&gt;
              &lt;min_power&gt;360&lt;/min_power&gt;
              &lt;max_power&gt;360&lt;/max_power&gt;
              &lt;average_usage_hour&gt;0.25&lt;/average_usage_hour&gt;
              &lt;average_usage_minute&gt;15&lt;/average_usage_minute&gt;
          &lt;/espresso_machine&gt;
          &lt;coffee_machine id="coffee machine"&gt;
              &lt;power&gt;1500&lt;/power&gt;
              &lt;min_power&gt;800&lt;/min_power&gt;
              &lt;max_power&gt;1500&lt;/max_power&gt;
              &lt;average_usage_hour&gt;0.25&lt;/average_usage_hour&gt;
              &lt;average_usage_minute&gt;15&lt;/average_usage_minute&gt;
          &lt;/coffee_machine&gt;
          &lt;coffee_pot id="coffee pot"&gt;
              &lt;power&gt;0&lt;/power&gt;
              &lt;min_power&gt;200&lt;/min_power&gt;
              &lt;max_power&gt;200&lt;/max_power&gt;
              &lt;average_usage_hour&gt;0.25&lt;/average_usage_hour&gt;
              &lt;average_usage_minute&gt;15&lt;/average_usage_minute&gt; 
          &lt;/coffee_pot&gt;
      &lt;/house&gt;
  &lt;/components&gt;
  </code></pre>
  
  <p>If I had to my program an "espresso machine" I should have the following output:</p>
  
  <p>[espresso_machine]
  [360]
  [360]
  [360]
  [0.25]
  [15]</p>
  
  <p>However, it comes out like this:</p>
  
  <p>[espresso_machine]
  []
  []
  []
  []
  []</p>
  
  <p>I thing the problem is in the Switch/Case when I use <code>innerElement.getTextTrim()</code> but I'm not sure. Can you help me fix this?</p>