how to access the title tag which is inside subcategory tag
sample.xml file
="1.0"="UTF-8"
<rss>
<item>
<id>1</id>
<title>Guidliness</title>
<desc>On the Internet usually the resume are send via e-mail to respective companies, but it is still important that you carry a copy along with you during your preliminary interview.</desc>
</item>
<item>
<id>2</id>
<title>Why do you Need a Resume?</title>
<desc>A summary of your objectives,educational qualification,experience,skills relevant to the field of work you are going to enter.</desc>
</item>
<item>
<id>3</id>
<title>Basics of Writing a Resume</title>
<subcategory>
<title>Basic Standards</title>
<desc>Resume is what an employer looks at much before meeting you,it is the first interface you have with your employer.</desc>
</subcategory>
<subcategory>
<title>Stick of the Point</title>
<desc>Employers have a busy schedule, so don't expect them to read through a long resume.</desc>
</subcategory>
<subcategory>
<title>Words Count</title>
<desc>Use of language is extremely important; you need to sell yourself to an employer quickly and efficiently.</desc>
</subcategory>
<subcategory>
<title>Make the Most of your Experience</title>
<desc>Employers need to know what you have accomplished to have an idea of what you can do for them. Don't be vague.</desc>
</subcategory>
<subcategory>
<title>Honesty is a Good Policy</title>
<desc>Employers will feel more comfortable hiring you if they can verify your accomplishments.</desc>
</subcategory>
<subcategory>
<title>Double-Check for Mistakes</title>
<desc>Check your resume for correct grammar and spelling - evidence of good communication skills and attention to detail.</desc>
</subcategory>
</item>
<item>
<id>4</id>
<title>15 Golden Steps</title>
<desc>The thought of writing a resume scares almost anyone. It's difficult to know where to start or what to include.</desc>
</item>
<item>
<id>5</id>
<title>8 Red Flags</title>
<desc>A Resume is your mirror reflection to a recruiter or prospective employer.</desc>
</item>
</rss>
SampleActivity.Java file in Android
public class AndroidXMLParsingActivity extends ListActivity {
static final String URL = "http://10.0.2.2:8080/sample/xmlfiles/sample.xml";
static final String RSS_ITEM = "item";
static final String RSS_ID = "id";
static final String RSS_NAME = "title";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ArrayList<hashmap><string,>> menuItems = new ArrayList<hashmap><string,>>();
XMLParser parser = new XMLParser();
String xml = parser.getXmlFromUrl(URL);
Document doc = parser.getDomElement(xml);
NodeList nl = doc.getElementsByTagName(RSS_ITEM);
for (int i = 0; i < nl.getLength(); i++)
{
HashMap<string,> map = new HashMap<string,>();
Element e = (Element) nl.item(i);
map.put(RSS_ID, parser.getValue(e, RSS_ID));
map.put(RSS_NAME, parser.getValue(e, RSS_NAME));
menuItems.add(map);
}
ListAdapter adapter = new SimpleAdapter(this, menuItems,R.layout.flist_item,new String[] { RSS_NAME }, new int[]
{
R.id.name
});
setListAdapter(adapter);
ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView {
String name = ((TextView) view.findViewById(R.id.name)).getText().toString();
Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
in.putExtra(RSS_NAME, name);
Log.d("name", name);
startActivity(in);
}
});
}
}</item></hashmap></hashmap>