for (int i = 0; i < nodes.getLength(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element) nodes.item(i);
String nameMapString = XMLfunctions.getValue(e, "name");
if(nameMapString.matches(".*+searchTextString1+.*")){
map.put("id", XMLfunctions.getValue(e, "id"));
map.put("name", "Name:" + XMLfunctions.getValue(e, "name"));
map.put("Score", "Score: " + XMLfunctions.getValue(e, "score"));
mylist.add(map);
}
}
I am writing an android program.
searchTextString is user provided value from EditText.
nameMapString holds value of name tag from xml file.
Suppose it may contain Mark, Marry, Jack, JackMar etc.
When i search Ma only, i want to display all which contain Ma (in this case Mark,Marry,JackMar). but above code display all name.
Sorry for my bad english.
You can try
indexOf(String str)method for it, see the updated code below,