for example I have xml file:
<names>
<item value="Hello" />
<item value="All" />
<item value="This" />
<item value="Data" />
</names>
So I need to get all raw data from the given attribute (names):
<item value="Hello" />
<item value="All" />
<item value="This" />
<item value="Data" />
In a string format, so the data should be:
String data = "
<item value="Hello" />
<item value="All" />
<item value="This" />
<item value="Data" />
";
and I have a peace of code:
int state = 0;
do {
try {
state = parser.next();
} catch (XmlPullParserException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
if (state == XmlPullParser.START_TAG) {
if (parser.getName().equals("names")) {
// here I need to get the data
// String data = ...
break;
}
}
} while(state != XmlPullParser.END_DOCUMENT);
so, how do I get data from xml element in string format?