Note that there are some explanatory texts on larger screens.

plurals
  1. POxml parsing and show the data in a list view
    primarykey
    data
    text
    <p>I have a xml file like [<code>this</code>][1] and i need to get the all the <code>"edition name"</code> according to the <code>"group name"</code> </p> <p>I have to create a list of group name and show the list of editions name on clicking of the group name. OutPut : </p> <p><img src="https://i.stack.imgur.com/yFJJx.png" alt="enter image description here"></p> <p>onclick of catalogs :</p> <p><img src="https://i.stack.imgur.com/VWpCg.png" alt="enter image description here"></p> <p>this xml is present in different languages, is there any way to get all the editions name without comparing with group name.</p> <p>currently i am using type tag to get all the catalogs :</p> <pre><code>if(parser.getValue(ele2, "type").toString().equalsIgnoreCase("catalog")) </code></pre> <p>But some <code>magazines</code> are also present in <code>catalogs</code> type. so not getting correct results ..</p> <p>How to get all the <code>editions name</code> where <code>group name</code> is <code>catalogs</code> and so on ...</p> <p>Or a better way to do so.. I am not sure the code I am using is a good approach. Kindly suggest.</p> <p>My code : </p> <pre><code>final String URL = "http://xml/web/?frg="+lang+"&amp;user="+count+"_"+user; System.out.println("URL child : " + URL); parser = new XMLParser(); String xml = parser.getXmlFromUrl(URL); // getting XML from URL doc = parser.getDomElement(xml); // getting DOM element NodeList n1 = doc.getElementsByTagName("groups"); for (int i = 0; i &lt; 1; i++) { //ToDo : worked temp Element e = (Element) n1.item(0); NodeList children = e.getChildNodes(); if(item_name.equalsIgnoreCase("Catalogs")||item_name.equalsIgnoreCase("Kataloge")) // there could be other languages { NodeList nodeList2 = doc.getElementsByTagName("edition"); for (int k = 0; k &lt; nodeList2.getLength(); k++) { HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); Element ele2 = (Element) nodeList2.item(k); if(parser.getValue(ele2, "type").toString().equalsIgnoreCase("catalog")) { System.out.println(""+parser.getValue(ele2, "name").toString()); System.out.println(""+parser.getValue(ele2, "cat_url").toString()); map.put(ss2, parser.getValue(ele2,ss2 )); map.put(KEY_THUMB_URL, parser.getValue(ele2, KEY_THUMB_URL)); map.put(CAT_URL, parser.getValue(ele2,"cat_url")); // adding HashList to ArrayList songsList.add(map); } } } if(item_name.equalsIgnoreCase("Magazines")||item_name.equalsIgnoreCase("Magazine")) { NodeList nodeList2 = doc.getElementsByTagName("edition"); for (int k = 0; k &lt; nodeList2.getLength(); k++) { HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); Element ele2 = (Element) nodeList2.item(k); if(parser.getValue(ele2, "type").toString().equalsIgnoreCase("pdf")) { System.out.println(""+parser.getValue(ele2, "name").toString()); System.out.println(""+parser.getValue(ele2, "cat_url").toString()); map.put(ss2, parser.getValue(ele2,ss2 )); map.put(KEY_THUMB_URL, parser.getValue(ele2, KEY_THUMB_URL)); map.put(CAT_URL, parser.getValue(ele2,"cat_url")); // adding HashList to ArrayList songsList.add(map); } } } if(item_name.equalsIgnoreCase("Instructions")) { NodeList n2 = doc.getElementsByTagName("groups"); for (int i1 = 0; i1 &lt; 1; i1++) { //ToDo : worked temp Element e1 = (Element) n2.item(0); NodeList children1 = e1.getChildNodes(); for (int j = 0; j &lt;children1.getLength(); j++) { HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); child = children1.item(j); // System.out.println("name node22 inside " + parser.getValue((Element)child, "name")); if(parser.getValue((Element)child, "name").equals("Instructions")) { if (child.getNodeName().equalsIgnoreCase("group")) { NodeList nl2 = child.getChildNodes(); System.out.println("Nodelist lenght : " + nl2.getLength()); for (int jj = 0; jj &lt;nl2.getLength(); jj++) { Node nn =nl2.item(jj); System.out.println("name node22 inside " + parser.getValue((Element)nn, "name")); } // map.put(KEY_TITLE, parser.getValue((Element)child,KEY_TITLE )); //map.put(KEY_THUMB_URL, parser.getValue((Element)child, KEY_THUMB_URL)); // adding HashList to ArrayList //songsList.add(map); } } } } } </code></pre> <p>Solved : Changed this :</p> <pre><code>Element e = (Element) n1.item(0); NodeList nodeList2 = doc.getElementsByTagName("edition"); </code></pre> <p>to this :</p> <pre><code>Element e = (Element) n1.item(0); NodeList nodeList2 = e.getElementsByTagName("edition"); </code></pre>
    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.
 

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