Note that there are some explanatory texts on larger screens.

plurals
  1. POfor loop inside try catch return without execute next line
    primarykey
    data
    text
    <p>I have a function for converting xml string to list array. while reaching the last condition,it jumps to the last return of the function.</p> <p>The code does not execute the return statement after the for loop.and it does not execute any line after the for loop. It just execute the last return statement.</p> <p>function is shown below</p> <pre><code>public List&lt;List&lt;String&gt;&gt; UpdateOrderDetailsTable(String xml) { List&lt;List&lt;String&gt;&gt; ll = new ArrayList&lt;List&lt;String&gt;&gt;(); try { DocumentBuilderFactory dbFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); InputStream is = new ByteArrayInputStream(xml.getBytes("UTF-8")); Document doc = dBuilder.parse(is); doc.getDocumentElement().normalize(); NodeList nList = doc.getElementsByTagName("ProductDetails"); Log.i("1111",Integer.toString(nList.getLength())); if (nList.getLength() &gt; 0) { // get all order details //i=1 for neglect first tag for (int i = 1; i &lt; nList.getLength(); i++) { Node nNode = nList.item(i); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) nNode; List&lt;String&gt; l = new ArrayList&lt;String&gt;(); l.add(0, eElement.getElementsByTagName("OrderId").item(0).getTextContent()); l.add(1, eElement.getElementsByTagName("ProductId").item(0).getTextContent()); l.add(2, eElement.getElementsByTagName("ProductName").item(0).getTextContent()); l.add(3, eElement.getElementsByTagName("Model").item(0).getTextContent()); l.add(4, eElement.getElementsByTagName("Quantity").item(0).getTextContent()); ll.add(l); Log.i(Integer.toString(i),eElement.getElementsByTagName("OrderId").item(0).getTextContent()); } } return ll; } Log.i("2222222222222222222","222222222222222222"); } catch (Exception e) { Log.e("11111", e.toString()); } return null; } </code></pre> <p><a href="http://smartcityjobs.in/sample.xml" rel="nofollow">this is my xml</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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