kianm98
kianm98

Reputation: 53

android - How to search in xml file

i have a XML file in : /res/xml/countries.xml

and also i have a view with editText inside.

i want to search that text (users should type in editText) in my countries.xml file!

here is my xml file :

<?xml version="1.0" encoding="utf-8"?>
  <countries>
     <country>
       <name>United State</name>
     </country>
  <countries>

Upvotes: 1

Views: 2581

Answers (4)

Pull
Pull

Reputation: 2246

This tutorial explain clearly how to parse an XML file : XML parser

Other tutorial simpler with XPath : Xparse tutorial

Upvotes: 0

grexter89
grexter89

Reputation: 1102

If you want to read a whole document, use XML Parser, like Pull already mentioned. If you only want to pick out only one or few certain things, I would suggest XPath. Here is a good Tutorial on how to use XPath in Java.

Upvotes: 2

Looking Forward
Looking Forward

Reputation: 3585

Try this xpath tutorial... You will have good learning experience...

Upvotes: 0

keshav
keshav

Reputation: 3255

First you need to parse that xml file containing the countries name. Store list of countries in any arraylist and then write any search algo to search the text found from that edittext.

Upvotes: 0

Related Questions