'How to extract a range of elements from xml file in python using minidom

I have a xml file like the following, and I want to extract the elements between 23th until 35th timestep elements and put them into an array using minidom python:

    <xml>
    <fcd>
    <?xml version="1.0" encoding="UTF-8"?>
<fcd-export xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/fcd_file.xsd">
    <timestep time="0.00"/>
    <timestep time="1.00">
        <vehicle id="myflow.0" x="5.10" y="998.40" angle="90.00" type="car" speed="14.25" pos="5.10" lane="e18_2" slope="0.00" acceleration="0.00"/>
    </timestep>
    <timestep time="2.00">
    </timestep>
    <timestep time="3.00">
     ...

what I tried is the following but I think its not a good approach.

   tt=doc.getElementsByTagName("timestep")
    for time in tt:
            if(float(time.getAttribute("time"))>23.00 and float(time.getAttribute("time"))<35.00):
              vehicles=time.getElementsByTagName("vehicle")


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source