Issue trying to pull in all cities/towns for a zip code using google api
<p>I'm using the google maps api to check an address users add by passing the zip code and returning a formatted address that I can compare to see if it matches.
This is the call:</p>

<pre><code>resultNodeList = (NodeList) xpath.evaluate("/GeocodeResponse/result/formatted_address", geocoderResultDocument, XPathConstants.NODESET)
</code></pre>

<p>The problem is some zipcode can be a part of mutiple cities/towns.
Here is the result for the google api for zip code 77380:</p>

<pre><code>&lt;GeocodeResponse&gt;
&lt;status&gt;OK&lt;/status&gt;
&lt;result&gt;
&lt;type&gt;postal_code&lt;/type&gt;
&lt;formatted_address&gt;Spring, TX 77380, USA&lt;/formatted_address&gt;
&lt;address_component&gt;
&lt;long_name&gt;77380&lt;/long_name&gt;
&lt;short_name&gt;77380&lt;/short_name&gt;
&lt;type&gt;postal_code&lt;/type&gt;
&lt;/address_component&gt;
&lt;address_component&gt;
&lt;long_name&gt;Spring&lt;/long_name&gt;
&lt;short_name&gt;Spring&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;Texas&lt;/long_name&gt;
&lt;short_name&gt;TX&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;United States&lt;/long_name&gt;
&lt;short_name&gt;US&lt;/short_name&gt;
&lt;type&gt;country&lt;/type&gt;
&lt;type&gt;political&lt;/type&gt;
&lt;/address_component&gt;
&lt;geometry&gt;...&lt;/geometry&gt;
&lt;postcode_locality&gt;Shenandoah&lt;/postcode_locality&gt;
&lt;postcode_locality&gt;Spring&lt;/postcode_locality&gt;
&lt;postcode_locality&gt;The Woodlands&lt;/postcode_locality&gt;
&lt;place_id&gt;ChIJUXEWvwI0R4YRWJe_Gb6C8Bk&lt;/place_id&gt;
&lt;/result&gt;
&lt;/GeocodeResponse&gt;
</code></pre>

<p>The user in this example lives in The Woodlands TX, not Spring TX. 
What I'm trying to do now is pull in the postcode_locality so that I can compare any of the cities/towns listed  (Shenandoah, Spring,The Woodlands)</p>

<p>I tired doing this :</p>

<pre><code>resultNodeList = (NodeList) xpath.evaluate("/GeocodeResponse/result/postcode_locality", geocoderResultDocument, XPathConstants.NODESET);
</code></pre>

<p>but I only got back Shenandoah.
I can do /GeocodeResponse/result/postcode_locality[1] and get each location manually but this code needs to work for any zip code entered.</p>

<p>Is there a way pull in a list of postcode_locality?</p>