while(eventType != XmlPullParser.END_DOCUMENT ) {
if(eventType == XmlPullParser.START_TAG) {
// 태그의 이름을 알아야 텍스트를 저장하기에 태그이름을 읽어서 변수에 저장
tagname = xpp.getName();
} else if(eventType == XmlPullParser.TEXT) {
// 태그 이름이 title과 같다면 변수에 title 저장
if(tagname.equals("title")) {
title += xpp.getText();
}
// 태그 이름이 description과 같다면 desc변수에 저장
else if (tagname.equals("description")) {
desc += xpp.getText();
}
else if (tagname.equals("author")){
author += xpp.getText();
}
else if (eventType == XmlPullParser.END_TAG) {
// end tag 이름을 얻어옴
tagname = xpp.getName();
// end tag 이름이 item이라면 저장한 변수 title과 desc를 벡터에 저장
if(tagname.equals("item")) {
titlevec.add(title);
descvec.add(desc);
authorvec.add(author);
// 변수 초기화
title="";
desc="";
author="";
}
}
}
안녕하세요 xmlpullparser를 이용해 파싱을 하고있습니다.
<item>
<title> 1~~~ </title>
<author>2 ~~~ </author>
<description>
<table>
3~~~~~~~~~~
</table>
4~~~~~~~~~~
</description>
</item>
위와같은 구조의 xml인데요
title이나 author description 안의 text는 잘 나옵니다.
헌데 description 안의 table 안의 text (3~~~~~~~) 를 뽑아내고싶은데 어떤식으로 해야할지 감이안옵니다 ㅠ_ㅠ
부탁드립니다 ㅠㅠ