Note that there are some explanatory texts on larger screens.

plurals
  1. POParse XML & Retrieve Info Several layers of Nodes Deep Java/Android
    text
    copied!<p>I am working from an example provided by my professor which gets data from a weather forecast site and parses the XML file to show the weather conditions in a list. My program is similar, but I want to retrieve information that is nested within several nodes, and I don't know how to get to it. Here is the XML file I'm working from:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;DirectionsResponse&gt; &lt;status&gt;OK&lt;/status&gt; &lt;route&gt; &lt;summary&gt;S Street Viaduct&lt;/summary&gt; &lt;leg&gt; &lt;step&gt; &lt;travel_mode&gt;DRIVING&lt;/travel_mode&gt; &lt;start_location&gt; &lt;lat&gt;40.7021400&lt;/lat&gt; &lt;lng&gt;-74.0158200&lt;/lng&gt; &lt;/start_location&gt; &lt;end_location&gt; &lt;lat&gt;40.7021400&lt;/lat&gt; &lt;lng&gt;-74.0158200&lt;/lng&gt; &lt;/end_location&gt; &lt;polyline&gt; &lt;points&gt;kslwFzewbM&lt;/points&gt; &lt;levels&gt;B&lt;/levels&gt; &lt;/polyline&gt; &lt;duration&gt; &lt;value&gt;0&lt;/value&gt; &lt;text&gt;1 min&lt;/text&gt; &lt;/duration&gt; &lt;html_instructions&gt;Head &amp;lt;b&amp;gt;east&amp;lt;/b&amp;gt; on &amp;lt;b&amp;gt;S Street Viaduct&amp;lt;/b&amp;gt;&lt;/html_instructions&gt; &lt;distance&gt; &lt;value&gt;0&lt;/value&gt; &lt;text&gt;1 ft&lt;/text&gt; &lt;/distance&gt; &lt;/step&gt; &lt;duration&gt; &lt;value&gt;0&lt;/value&gt; &lt;text&gt;1 min&lt;/text&gt; &lt;/duration&gt; &lt;distance&gt; &lt;value&gt;0&lt;/value&gt; &lt;text&gt;1 ft&lt;/text&gt; &lt;/distance&gt; &lt;start_location&gt; &lt;lat&gt;40.7021400&lt;/lat&gt; &lt;lng&gt;-74.0158200&lt;/lng&gt; &lt;/start_location&gt; &lt;end_location&gt; &lt;lat&gt;40.7021400&lt;/lat&gt; &lt;lng&gt;-74.0158200&lt;/lng&gt; &lt;/end_location&gt; &lt;start_address&gt;S Street Viaduct, New York, NY 10004, USA&lt;/start_address&gt; &lt;end_address&gt;S Street Viaduct, New York, NY 10004, USA&lt;/end_address&gt; &lt;/leg&gt; &lt;copyrights&gt;Map data ©2010 Google, Sanborn&lt;/copyrights&gt; &lt;overview_polyline&gt; &lt;points&gt;kslwFzewbM&lt;/points&gt; &lt;levels&gt;B&lt;/levels&gt; &lt;/overview_polyline&gt; &lt;/route&gt; &lt;/DirectionsResponse&gt; </code></pre> <p>I'm really only interested in retrieving the info in the "html_instructions" tag, but it is nested in the "route", "leg", and "step" tags. I have seen several tutorials and questions on SO about parsing XML but couldn't seem to find a solution to this. Any direction would be greatly appreciated!</p> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload