I am getting an XML text from a web service. I have successfully loaded the stream XmlPullParser object by getting parser.setInput(con.getInputStream(),null);
where parser is my XmlPullParser object and con is my connection to the URL.
I am reading the stream but I don't know how to get specific parts to it. This is how the XML file looks like:
`<response>
<list><category>(noun)</category><synonyms>order|war (antonym)</synonyms></list>
<list><category>(noun)</category><synonyms>harmony|concord|concordance</synonyms></list>
<list><category>(noun)</category><synonyms>public security|security</synonyms></list>
<list><category>(noun)</category><synonyms>peace treaty|pacification|treaty|pact|accord</synonyms></list>
</response>`
I would like access the text within in the <synonyms>
tags but not sure how to do that. This is what I have:
int eventType = parser.getEventType();
while(eventType != XmlPullParser.END_DOCUMENT){
String name = parser.getName();
if(eventType == XmlPullParser.TEXT) {
stringToBeDisplayed.add(parser.getText()+"\n");
}
eventType = parser.next();
}
But the above code gets the Text within the <category>
tag and the <synonyms>
which I dont want. I only want the text enclosed in the <synonyms>
tag.