Я использую логическую переменную "stopParse
" для приема слушателей, так как я не люблю использовать throw new SAXException()
;
private boolean stopParse;
article.getChild("title").setEndTextElementListener(new EndTextElementListener(){
public void end(String body) {
if(stopParse) {
return; //if stopParse is true consume the listener.
}
setTitle(body);
}
});
Обновление:
@ PanuHaaramo, возможно, это будет .xml
<root>
<article>
<title>Jorgesys</title>
</article>
<article>
<title>Android</title>
</article>
<article>
<title>Java</title>
</article>
</root>
синтаксический анализатор для получения значения "title" с использованием android SAX должен быть:
import android.sax.Element;
import android.sax.EndTextElementListener;
import android.sax.RootElement;
...
...
...
RootElement root = new RootElement("root");
Element article= root.getChild("article");
article.getChild("title").setEndTextElementListener(new EndTextElementListener(){
public void end(String body) {
if(stopParse) {
return; //if stopParse is true consume the listener.
}
setTitle(body);
}
});