안드로이드 개발 질문/답변
(글 수 45,052)
try {
//파서
URL url = new URL("http://www.yyg.go.kr/open_content/participation/region_monitor/");
InputStream is = url.openConnection().getInputStream();
//InputStream is = url.openStream();
XmlPullParserFactory parserFactory = XmlPullParserFactory.newInstance();
XmlPullParser parser = Xml.newPullParser();
parser.setInput(is, null);
int parserEvent = parser.getEventType();
while (true) {
int type=parser.next();
//다큐먼트시작
if (type==XmlPullParser.START_DOCUMENT) {
str="type=START_DOCUMENT"+
",text="+parser.getText()+
",depth="+parser.getDepth();
strs.add(str);
Log.d("PBS",str);
}
//태그시작
else if (type==XmlPullParser.START_TAG) {
str="type=START_TAG"+
",text="+parser.getText()+
",depth="+parser.getDepth();
strs.add(str);
Log.d("PBS",str);
//속성
str=" attribute,";
for (int i=0;i<parser.getAttributeCount();i++) {
str+=parser.getAttributeName(i)+"="+parser.getAttributeValue(i)+",";
strs.add(str);
}
}
//텍스트
else if (type==XmlPullParser.TEXT) {
str="type=TEXT"+
",text="+parser.getText()+
",depth="+parser.getDepth();
strs.add(str);
Log.d("PBS",str + " 1");
}
//태그종료
else if (type==XmlPullParser.END_TAG) {
str="type=END_TAG"+
",text="+parser.getText()+
",depth="+parser.getDepth();
strs.add(str);
Log.d("PBS",str + " 1");
}
//다큐먼트종료
else if (type==XmlPullParser.END_DOCUMENT) {
str="type=END_DOCUMENT"+
",text="+parser.getText()+
",depth="+parser.getDepth();
strs.add(str);
Log.d("PBS",str + " 2");
break;
}
}
} catch (Exception e) {
Log.e("PBS","error : " + e.toString());
Log.d("PBS","go the failse");
}
소스는 일단 이렇고요
다른 rss는 확인해서 돌려보니까 잘 돌아가는데,
제가 파싱하려는 주소가..
http://www.yyg.go.kr/open_content/organization/military_news/efocus/rss
http://www.yyg.go.kr/open_content/participation/freeboard/rss
http://www.yyg.go.kr/open_content/participation/region_monitor/rss
이거 3개인데 돌리기만 하면
02-09 01:22:07.694: ERROR/PBS(19364): error : java.io.FileNotFoundException: http://www.yyg.go.kr/open_content/participation/freeboard/rss
이런 에러가 뜹니다.
rss 소스 뜯어보니
<rss version="2.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:atom="http://www.w3.org/2005/Atom" >이것만 다릅니다.
일반 rss 는 <rss version="2.0"> 에서 element가 끝나고요..
혹시 이런 걸로 exception이 뜰 수도 있는건가요
혹시나 돌아 가시는 분 계시면 소스 좀 보내 주실 수 없나요..



