My XML looks like:
<key>A</key>
How do I extract the string "A" from the XML with java in Eclipse? My Java code looks like:
XmlResourceParser xmlSymptoms = getResources().getXml(R.xml.symptoms);
while (eventType != XmlResourceParser.END_DOCUMENT) {
if (eventType == XmlResourceParser.START_TAG) {
// Get the name of the tag (eg scores or score)
String strName = xmlSymptoms.getName();
if (strName.equals("key")) {
keyName = xmlSymptoms.getAttributeName(0);
keyA = xmlSymptoms.getAttributeValue(0);
}
}
eventType = xmlSymptoms.next();
}
But I think AttributeName and AttributeValue are for items that are part of the key description, i.e. they would be used to obtain "item" and "first".
<key item="first">A</key>
What do I use to obtain the string between
"<key>
"
and
"</key>
"?