title: How do I limit a loop over xml-elements by its attributes?
body: <p>I feel like I'm stuck and would really appreciate all forms of help and guidance. </p>
  
  <p>I have an XML downloaded from yr.no (norweigan weather report). It contains several elements with weather reports from different times of the day. It has 3 reports per day but I just want to use one of them and I want to print out the weather for the next 7 days. I have so far managed to print out the weather for all days, or just one. I have however not figured how to "sort out" the ones from the wrong time period.</p>
  
  <p>This is my latest attempt to just get 1 out of 3 reports. Every report is in three elements, what makes them unique is their attributes. I will below my code show a couple of lines from the xml. If your want to download the whole xml to see the structure, I will put a link to that at the bottom. </p>
  
  <p>My latest attempt:</p>
  
  <pre><code>with open('Stockholm.xml', 'rt') as wreport:
      tree = ET.parse(wreport)
  
  for temp in tree.getiterator("temperature"):
      counter = 2
      if counter == 0 or counter == 1:
          counter += 1
      elif counter == 2:
          counter -= 2
          print "In Stockholm it will today be %s celcius" % (temp.get("value"))
  </code></pre>
  
  <p>The XML, from which I would like to reach the element "temperature" from the first seven elements named "time" that got period="2":</p>
  
  <pre><code>&lt;forecast&gt;
   &lt;tabular&gt;
     &lt;time from="2014-01-03T12:00:00" to="2014-01-03T18:00:00" period="2"&gt;
      &lt;!--
      Valid from 2014-01-03T12:00:00 to 2014-01-03T18:00:00 
      --&gt;
      &lt;symbol number="4" name="Skya" var="04"/&gt;
      &lt;precipitation value="0.1" minvalue="0.1" maxvalue="0.2"/&gt;
      &lt;!--  Valid at 2014-01-03T12:00:00  --&gt;
      &lt;windDirection deg="163.3" code="SSE" name="Sør-søraust"/&gt;
      &lt;windSpeed mps="4.6" name="Lett bris"/&gt;
      &lt;temperature unit="celsius" value="4"/&gt;
      &lt;pressure unit="hPa" value="1007.0"/&gt;
     &lt;/time&gt;
  &lt;time from="2014-01-03T18:00:00" to="2014-01-04T00:00:00" period="3"&gt;...&lt;/time&gt;
  &lt;time from="2014-01-04T00:00:00" to="2014-01-04T06:00:00" period="0"&gt;...&lt;/time&gt;
  &lt;time from="2014-01-04T06:00:00" to="2014-01-04T12:00:00" period="1"&gt;...&lt;/time&gt;
  </code></pre>
  
  <p>In all of the  you can get the same elements that I showed in the first time. Download link here: <a href="http://www.yr.no/stad/Sverige/Stockholm/Stockholm/varsel.xml" rel="nofollow">http://www.yr.no/stad/Sverige/Stockholm/Stockholm/varsel.xml</a></p>