How can i read the text between xml tags using xml.etree.Elementree ?If the xml is complex
<pre><code>&lt;GeocodeResponse&gt;
&lt;status&gt;OK&lt;/status&gt;
&lt;result&gt;
&lt;type&gt;locality&lt;/type&gt;
&lt;type&gt;political&lt;/type&gt;
&lt;formatted_address&gt;Chengam, Tamil Nadu 606701, India&lt;/formatted_address&gt;
&lt;address_component&gt;
&lt;long_name&gt;Chengam&lt;/long_name&gt;
&lt;short_name&gt;Chengam&lt;/short_name&gt;
&lt;type&gt;locality&lt;/type&gt;
&lt;type&gt;political&lt;/type&gt;
&lt;/address_component&gt;
&lt;address_component&gt;
&lt;long_name&gt;Tiruvannamalai&lt;/long_name&gt;
&lt;short_name&gt;Tiruvannamalai&lt;/short_name&gt;
&lt;type&gt;administrative_area_level_2&lt;/type&gt;
&lt;type&gt;political&lt;/type&gt;
&lt;/address_component&gt;
&lt;address_component&gt;
&lt;long_name&gt;Tamil Nadu&lt;/long_name&gt;
&lt;short_name&gt;TN&lt;/short_name&gt;
&lt;type&gt;administrative_area_level_1&lt;/type&gt;
&lt;type&gt;political&lt;/type&gt;
&lt;/address_component&gt;
&lt;address_component&gt;
&lt;long_name&gt;India&lt;/long_name&gt;
&lt;short_name&gt;IN&lt;/short_name&gt;
&lt;type&gt;country&lt;/type&gt;
&lt;type&gt;political&lt;/type&gt;
&lt;/address_component&gt;
&lt;address_component&gt;
&lt;long_name&gt;606701&lt;/long_name&gt;
&lt;short_name&gt;606701&lt;/short_name&gt;
&lt;type&gt;postal_code&lt;/type&gt;
&lt;/address_component&gt;
&lt;geometry&gt;
&lt;location&gt;
&lt;lat&gt;12.3067864&lt;/lat&gt;
&lt;lng&gt;78.7957856&lt;/lng&gt;
&lt;/location&gt;
&lt;location_type&gt;APPROXIMATE&lt;/location_type&gt;
&lt;viewport&gt;
&lt;southwest&gt;
&lt;lat&gt;12.2982423&lt;/lat&gt;
&lt;lng&gt;78.7832165&lt;/lng&gt;
&lt;/southwest&gt;
&lt;northeast&gt;
&lt;lat&gt;12.3213030&lt;/lat&gt;
&lt;lng&gt;78.8035583&lt;/lng&gt;
&lt;/northeast&gt;
&lt;/viewport&gt;
&lt;bounds&gt;
&lt;southwest&gt;
&lt;lat&gt;12.2982423&lt;/lat&gt;
&lt;lng&gt;78.7832165&lt;/lng&gt;
&lt;/southwest&gt;
&lt;northeast&gt;
&lt;lat&gt;12.3213030&lt;/lat&gt;
&lt;lng&gt;78.8035583&lt;/lng&gt;
&lt;/northeast&gt;
&lt;/bounds&gt;
&lt;/geometry&gt;
&lt;place_id&gt;ChIJu8JCb3jxrDsRAOfhACQczWo&lt;/place_id&gt;
&lt;/result&gt;
&lt;/GeocodeResponse&gt;
</code></pre>

<p>I am new to xml thing and i don't know how to handle it with python xml.etree ? Basic stuffs i read from <a href="https://docs.python.org/2/library/xml.etree.elementtree.html#parsing-xml" rel="nofollow">https://docs.python.org/2/library/xml.etree.elementtree.html#parsing-xml</a> is useful,but still struggling to printout the latitude and longitude values under geometry-->location.i have tried something like this</p>

<pre><code>        with open('data.xml', 'w') as f:
            f.write(xmlURL.text)
        tree = ET.parse('data.xml')
        root = tree.getroot()
        lat = root.find(".//geometry/location")
        print(lat.text)
</code></pre>

<p>You almost got it. Change <code>root.find(".//geometry/location")</code> to <code>root.find(".//geometry/location/lat")</code>:</p>

<pre><code>lat = root.find(".//geometry/location/lat")
print(lat.text)
&gt;&gt; 12.3067864
</code></pre>

<p>Same goes for <code>lng</code> of course:</p>

<pre><code>lng = root.find(".//geometry/location/lng")
print(lng.text)
&gt;&gt; 78.7957856
</code></pre>

python xml.etree