Note that there are some explanatory texts on larger screens.

plurals
  1. POGet0ingt value from Node doesnt work, android
    text
    copied!<p>Everything is ok. Getting xml from internet, parsing to Document but when I am trying to get some value from node ()and some between one node (Very cloudy.)</p> <pre><code>private void parseWeather(Document srcDoc) throws Exception { for (int a = 0; a &lt; srcDoc.getElementsByTagName("record").getLength(); a++){ Node recordNode = srcDoc.getElementsByTagName("record").item(a); Node temperatureNode = srcDoc.getElementsByTagName("temperature").item(a); Node windNode = srcDoc.getElementsByTagName("wind").item(a); Node bioNode = srcDoc.getElementsByTagName("bio").item(a); RECORD = recordNode.getAttributes().getNamedItem("date").getNodeValue().toString(); TEMPERATURE = temperatureNode.getAttributes().getNamedItem("min").getNodeValue().toString(); WIND = windNode.getAttributes().getNamedItem("speed").getNodeValue().toString(); BIO = bioNode.getAttributes().getNamedItem("value").getNodeValue().toString(); Element element= (Element) srcDoc.getElementsByTagName("record").item(a); NodeList status = element.getElementsByTagName("status"); NodeList text = element.getElementsByTagName("text"); Node statusNode = status.item(0); Node textNode = text.item(0); String statusText = statusNode.getFirstChild().getNodeValue(); String textText = textNode.getFirstChild().getNodeValue(); Log.e("Values", "STatus is " + statusText + " and text is " + textText); } } </code></pre> <p>and this is xml file</p> <pre><code>&lt;root&gt; &lt;forecast&gt; &lt;record date="24-10-2012"&gt; &lt;temperature max="17" min="3" unit="°C" /&gt; &lt;wind speed="2 až 5" direction="SV" unit="m/s" /&gt; &lt;bio value="2" /&gt; &lt;status symbol="3"&gt;Fair&lt;/status&gt; &lt;text&gt;Very fair today.&lt;/text&gt; &lt;warnings /&gt; &lt;/record&gt; &lt;record date="25-10-2012"&gt; &lt;temperature max="16" min="2" unit="°C" /&gt; &lt;wind speed="2 až 5" direction="Juhozápadný" unit="m/s" /&gt; &lt;bio value="3" /&gt; &lt;status symbol="3"&gt;Cloudy&lt;/status&gt; &lt;text&gt;Very cloudy tommorow. &lt;/text&gt; &lt;warnings /&gt; &lt;/record&gt; &lt;record date="25-10-2012"&gt; &lt;temperature max="16" min="2" unit="°C" /&gt; &lt;wind speed="2 až 5" direction="Juhozápadný" unit="m/s" /&gt; &lt;bio value="3" /&gt; &lt;status symbol="3"&gt;Cloudy&lt;/status&gt; &lt;text&gt;Very cloudy tommorow. &lt;/text&gt; &lt;warnings /&gt; &lt;/record&gt; </code></pre> <p> </p> <p>I get the output for record, temperature, wind a bio but not for status and text. And this loop will do only ones. Can anybody help me?</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