Reputation: 129
i want parse this webpage on my android app:
<?xml version="1.0" encoding="UTF-8"?>
<hello>
<world>
<a></a>
<b><![CDATA[one]]></b>
<c><![CDATA[two]]></c>
<d><![CDATA[three]]></d>
<e><![CDATA[four]]></e>
<f><![CDATA[five]]></f>
</world>
<world>
<a></a>
<b><![CDATA[test1]]></b>
<c><![CDATA[test2]]></c>
<d><![CDATA[test3]]></d>
<e><![CDATA[test4]]></e>
<f><![CDATA[test5]]></f>
</world>
<world>
.....more
</world>
</hello>
I want extract : one, two, three, four, five and test1...and more..
Upvotes: 0
Views: 70
Reputation: 8738
You can use Jsoup
in this way:
Document doc = Jsoup.parse(xml, "", Parser.xmlParser());
Elements elements = doc.select("hello world *");
for (Element element : elements) {
if(!element.tagName().equals("a")){
System.out.println("Text: " + element.text());
}
}
Output will be:
Text: one
Text: two
Text: three
Text: four
Text: five
Text: test1
Text: test2
Text: test3
Text: test4
Text: test5
Upvotes: 2