how to get specific value in xml parsing by write in edittext

后端 未结 1 1473
旧时难觅i
旧时难觅i 2021-01-27 23:29

i found this tutorial which show xml parsing but is show all values in xml file on 1st screen i want tomodify this code and add edittextbox which show only that value attributes

相关标签:
1条回答
  • 2021-01-28 00:00

    Yes you can , in the code section below :

    for (int i = 0; i < nl.getLength(); i++) {
            // creating new HashMap
            HashMap<String, String> map = new HashMap<String, String>();
            Element e = (Element) nl.item(i);
    
            if(parser.getValue(e, KEY_ID).equals(et.getText().toString())){
            // adding each child node to HashMap key => value
            map.put(KEY_ID, parser.getValue(e, KEY_ID));
            map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
            map.put(KEY_COST, "Rs." + parser.getValue(e, KEY_COST));
            map.put(KEY_DESC, parser.getValue(e, KEY_DESC));
    
            // adding HashList to ArrayList
            menuItems.add(map);
    }else{
     }
    

    As you can see , you just retrieve the id from XML and compare it to the id you get from the Edit text. If they match add it to the hashmap else dont !

    Hope this helps!

    0 讨论(0)
提交回复
热议问题