я хочу разобрать страну она присутствует в папке xml
<My_location_country>
<Country_str_code>AW</Country_str_code>
<Country_str_name>Aruba</Country_str_name>
</my_location_country>
.......................
я хочу отобразить название страны в адаптере массива, когда я выбираю страну, я хочу, чтобы код страны печатался, я использую следующий метод, но он не работает
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
DefaultHandler handler = new DefaultHandler() {
boolean countryflag = false;
boolean countryidflag = false;
public void startElement(String uri, String localName,String qName,
Attributes attributes) throws SAXException {
System.out.println("Start Element :" + qName);
if (qName.equalsIgnoreCase("Country_str_code")) {
countryidflag = true;
}
if (qName.equalsIgnoreCase("Country_str_name")) {
countryflag = true;
}
}
public void endElement(String uri, String localName,
String qName) throws SAXException {
System.out.println("End Element :" + qName);
}
public void characters(char ch[], int start, int length) throws SAXException {
if (countryidflag) {
System.out.println("Country_str_code" + new String(ch, start, length));
String val=new String(ch, start, length);
countryid.add(val);
countryidflag = false;
}
if (countryflag) {
System.out.println("Country_str_name " + new String(ch, start, length));
String val1=new String(ch, start, length);
countryname.add(val1);
countryflag = false;
}
}
};
File file = new File("res/xml/country.xml");
InputStream inputStream= new FileInputStream(file);
Reader reader = new InputStreamReader(inputStream,"UTF-8");
InputSource is = new InputSource(reader);
is.setEncoding("UTF-8");
//saxParser.parse();
} catch (Exception e) {
e.printStackTrace();
}
в расположении файла я получаю ошибку
любая помощь .............. спасибо заранее