프레임워크/Android

안드로이드에서 XML 데이터 파싱하기

트리맨스 2020. 7. 10. 17:21
반응형

 

공개된 공공데이터 (날씨 정보 및 버스 정보 등) 를 이용하기 위해서는 데이터를 분석하고 분류할 줄 알아야 한다. 이러한 데이터의 형식은 여러 가지가 있지만 주로 XML 데이터를 이용한다. 안드로이드에서는 기본적으로 XML을 분류하고 처리할 수 있는 기능을 제공한다. XmlPullParser라고 되어 있는 기능이 있다. 아래 사이트에 가면 이것에 대한 내용이 나와 있다.

https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser

 

비슷한 기능으로 jsoup이 있으나 공공데이터를 파싱하여 분류하기에는 적합하지 않다. 기본적으로 탑재되어 있는 기능을 사용하는 것이 매우 좋다. 내가 공공데이터를 이용할 때 사용했던 코드가 있다. 예시 코드를 살펴보면서 알아보자. 논문 정보를 파싱하는 코드이다. 참고로 액티비티 파일의 전체가 아니라 파싱하는 기능만 추출한 코드이다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
public class GetArticleDataAsync extends AsyncTask<StringString, com.example.assignment.ResultClass> {
 
        ResultClass AsyncResultClass = new ResultClass();
 
        @Override
        protected com.example.assignment.ResultClass doInBackground(String... strings) {
 
            boolean journal_name = false, publisher_name = false, pub_year = false, title = false, title_tag = true, author = false, url_ = false, record = false;
            String Author = "";
 
            //xml 파싱을 시작한다.
            //xml 파싱은 시작태그, 종료태그, 내용태그를 구분하는 것이 기본이다.
            //다음 태그로 넘어갈 때 while문을 한번 돌게 된다.
            //원하는 시작태그가 나오면 그 태그에 맞는 boolean을 true로 해준다.
            //목표한 태그가 true값을 가지게 되면 내용태그(내용)를 백터에 추가한다.
 
            try{
                Apiurl = new URL(url);
                InputStream input = Apiurl.openStream();
                XmlPullParserFactory parsers = XmlPullParserFactory.newInstance();
                XmlPullParser parser = parsers.newPullParser();
                parser.setInput(input,"UTF-8");
 
                //데이터 분석 시작, 한번에 한 개의 태그를 분석한다.
                while(parser.getEventType() != XmlPullParser.END_DOCUMENT){
 
                    //파싱한 데이터의 타입 변수를 저장한다. 시작태그, 텍스트태그, 종료태그를 구분한다.
                    int type = parser.getEventType();
 
                    //조건에 맞는 데이터가 발견되면 각 데이터에 맞게 대입한다.
                    if(journal_name) {
                        JournalArray.add(parser.getText());
                        journal_name = false;
                    } else if(publisher_name) {
                        JournalNameArray.add(parser.getText());
                        publisher_name = false;
                    } else if(pub_year) {
                        YearArray.add(parser.getText());
                        pub_year = false;
                    } else if(title && title_tag) {
                        //제목은 한글 제목만 추출한다.
                        TitleArray.add(parser.getText());
                        title_tag = false;
                    } else if(url_) {
                        UrlArray.add(parser.getText());
                        url_ = false;
                    } else if(author && type == XmlPullParser.TEXT && record) {
                        //공동저자일 경우가 있으므로 ArrayList에 저장
                        //빈칸이 있는 경우가 있다. 빈칸을 없애기 위하여 trim 함수를 사용한다.
                        Author = Author.trim() + "\n" + parser.getText().trim();
                        System.out.println(parser.getText());
                    } else if(type == XmlPullParser.END_TAG && parser.getName().equals("author-group")) {
                        author = false;
                    } else if(type == XmlPullParser.END_TAG && parser.getName().equals("record")) {
                        //마지막 태그일때는 한 개의 논문에 대한 정보 result 1 칸에 저장, resultClass는 초기화
                        title_tag = true;
                        title = false;
                        record = false;
                        AuthorArray.add(Author);
                        Author = "";
                    } else if(type == XmlPullParser.END_TAG && parser.getName().equals("author")) {
                        author = false;
                    }
 
                    //원하는 태그의 값이 나올 경우에 그 항목에 대한 boolean을 true로 지정
                    if(type == XmlPullParser.START_TAG && parser.getName().equals("journal-name")) {
                        journal_name = true;
                    } else if(type == XmlPullParser.START_TAG && parser.getName().equals("publisher-name")) {
                        publisher_name = true;
                    } else if(type == XmlPullParser.START_TAG && parser.getName().equals("pub-year")) {
                        pub_year = true;
                    } else if(type == XmlPullParser.START_TAG && parser.getName().equals("article-title")) {
                        title = true;
                    } else if(type == XmlPullParser.START_TAG && parser.getName().equals("author")) {
                        author = true;
                    } else if(type == XmlPullParser.START_TAG && parser.getName().equals("url")) {
                        url_ = true;
                    } else if(type == XmlPullParser.START_TAG && parser.getName().equals("record")) {
                        record = true;
                    }
 
                    /*
                    //파싱 확인을 위한 코드
                    if(type == XmlPullParser.START_DOCUMENT){
                        System.out.println("Start Doc");
                    } else if(type == XmlPullParser.START_TAG){
                        System.out.println("Start Tag " + parser.getName());
                    } else if(type == XmlPullParser.END_TAG){
                        System.out.println("End Tag " + parser.getName());
                    } else if(type == XmlPullParser.TEXT){
                        System.out.println(parser.getText());
                    }
                     */
 
                    type = parser.next();
 
                    }
                } catch (XmlPullParserException ex) {
                ex.printStackTrace();
            } catch (MalformedURLException ex) {
                ex.printStackTrace();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
 
            //리턴할 클래스에 모은 데이터 전송
            AsyncResultClass.JournalArray = JournalArray;
            AsyncResultClass.JournalNameArray = JournalNameArray;
            AsyncResultClass.YearArray = YearArray;
            AsyncResultClass.CategoryVector = CategoryVector;
            AsyncResultClass.TitleArray = TitleArray;
            AsyncResultClass.AuthorArray = AuthorArray;
            AsyncResultClass.UrlArray = UrlArray;
 
            return AsyncResultClass;
        }
    }
cs

 

아래 데이터는 파싱한 데이터의 원본이다. 개인정보 침해의 소지가 있는 데이터는 다른 데이터로 대체했다

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
<MetaData>
<inputData>
<key>userkey</key>
<apiCode>articleSearch</apiCode>
<title>컴퓨터</title>
<dateFrom>200001</dateFrom>
<dateTo>202001</dateTo>
<page>1</page>
<displayCount>10</displayCount>
</inputData>
<outputData>
<result>
<total>3612</total>
</result>
<record>
<journalInfo>d
<journal-name>유아교육연구</journal-name>
<publisher-name>한국유아교육학회</publisher-name>
<pub-year>2011</pub-year>
<pub-mon>10</pub-mon>
<volume>31</volume>
<issue>5</issue>
</journalInfo>
<articleInfo article-id="ART001601291">
<article-categories>교육학</article-categories>
<article-regularity>Y</article-regularity>
<title-group>
<article-title lang="original">
<![CDATA[ 컴퓨터 통합교육 정도와 관련된 유아교사의 내적 변인들 간의 구조모형 분석- 구성주의 교수신념, 일반적 교수효능감, 컴퓨터 교육에 대한 태도  컴퓨터 교수효능감을 중심으로 ]]>
</article-title>
<article-title lang="foreign">
<![CDATA[ A causal model of early childhood teacher’s educational beliefs and computer integration education level- Focusing on the effects of constructivist teaching beliefs, general-teaching self-efficacy, computer attitudes, and computer teaching self-efficacy ]]>
</article-title>
<article-title lang="english">
<![CDATA[ A causal model of early childhood teacher’s educational beliefs and computer integration education level- Focusing on the effects of constructivist teaching beliefs, general-teaching self-efficacy, computer attitudes, and computer teaching self-efficacy ]]>
</article-title>
</title-group>
<author-group>
<author>유은영(경원대학교)</author>
</author-group>
<abstract-group>
<abstract lang="original">
<![CDATA[  연구는 유아교사의 컴퓨터 통합교육 정도와 내적 신념(구성주의 교수신념, 일반적 교수효능감, 컴퓨터 교육에 대한 태도, 컴퓨터 교수효능감) 간의 인과관계를 구조방정식을 통하여 확인하였다. 연구 참여자는 서울  경기도와 부산에 있는 유치원과 어린이집의 교사 196명이었다. 유아교사의 내적 신념이 어떠한 인과관계를 통해 컴퓨터 통합교육 정도에 영향을 주는지를 살펴보기 위하여 선행연구를 바탕으로 연구모형을 설정하고 구조분석을 실시하였다. 연구모형  요인계수가 낮은 경로를 수정하여 연구모형과 수정된 연구모형의 적합도를 비교·분석하였다. 분석 결과 수정된 연구모형의 적합지수가 연구모형에 비해 양호한 것으로 나타나서 이를 최종모형으로 선정하였다. 연구결과 유아교사의 내적 신념  특히 구성주의 교수신념은 다른 신념들과 직·간접적 인과관계를 통해 유아교사의 컴퓨터 통합교육 정도에 영향을 미치는 것으로 나타났다. 연구 결과를 바탕으로 유아교사의 구성주의 교수신념을 높일  있는 교사 컴퓨터 교육이 필요하며, 유아교사의 내적 신념에 영향을 주는 인구·사회학적 변인들을 고려한 체계적인 구조분석이 추후에 필요함을 제안하였다. ]]>
</abstract>
<abstract lang="english">
<![CDATA[ The purpose of this study was to predict the levels of early childhood educator's computer integration using the variables of teachers' educational beliefs: constructivist teaching beliefs, general-teaching self-efficacy, computer attitudes, and computer- teaching self-efficacy. A total of 196 early childhood educators for 3-5 year old children in Seoul, Kyounggi-do, and Pusan responded to a set of questionnaires measuring their educational beliefs and computer integration levels. The questionnaire had five scales to collect data: Constructivist Teaching Beliefs(Woolley, Benjamin, Woolley, 2004), Ohio State Teacher Efficacy Scale(Tschannen & Woolfolk, 2001), The Microcomputer Utilization in Teaching Efficacy Beliefs Instrument(Enochs, Riggs, & Ellis, 1993), Attitudes toward Computer in Education Scale(van Braak, 2001), and The Prospective Computer Use Scale(van Braak, Tondeur, & Valcke, 2004). To investigate the structure of teacher's educational beliefs and their relationships with computer integration education, a theoretical model was developed, assuming that all teachers' educational beliefs had direct and indirect effects on teacher's computer integration education levels. The structural equation model was used to find a suitable model based on the developed model to explain the teachers' computer integration level. The finding of this study revealed that early childhood educator's constructivist teaching beliefs, computer attitudes, and computer-teaching self-efficacy predicted directly the level of teacher's computer integration education. It also demonstrated that teachers' constructivist teaching beliefs, general-teaching self-efficacy, computer attitudes predicted indirectly the level of teachers' computer integration education. Based on the findings of the present study, some implications were suggested for future study to further the constructivist teaching beliefs and to do structure-centered research including teachers' socio-demographic variables for understanding the role of teachers' thinking processes in computer integration education. ]]>
</abstract>
</abstract-group>
<fpage>463</fpage>
<lpage>480</lpage>
<doi>
<![CDATA[ http://dx.doi.org/10.18023/kjece.2011.31.5.020 ]]>
</doi>
<uci>G704-000049.2011.31.5.001</uci>
<citation-count>11</citation-count>
<url>
<![CDATA[ https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART001601291 ]]>
</url>
<verified>Y</verified>
</articleInfo>
</record>
<record>
<journalInfo>
<journal-name>한국디자인문화학회지</journal-name>
<publisher-name>한국디자인문화학회</publisher-name>
<pub-year>2015</pub-year>
<pub-mon>03</pub-mon>
<volume>21</volume>
<issue>1</issue>
</journalInfo>
<articleInfo article-id="ART001974776">
<article-categories>디자인</article-categories>
<article-regularity>Y</article-regularity>
<title-group>
<article-title lang="original">
<![CDATA[ 컴퓨터적 사고를 기반으로  컴퓨터 교육에 디자인적 사고 적용에 관한 연구 - 초등학교 컴퓨터 교육을 중심으로 - ]]>
</article-title>
<article-title lang="foreign">
<![CDATA[ A Study of Design Thinking Adaptation to Computer Education Based on Computational Thinking -Focused on Computer Education for Elementary School- ]]>
</article-title>
<article-title lang="english">
<![CDATA[ A Study of Design Thinking Adaptation to Computer Education Based on Computational Thinking -Focused on Computer Education for Elementary School- ]]>
</article-title>
</title-group>
<author-group>
<author>이지선(숙명여자대학교)</author>
</author-group>
<abstract-group>
<abstract lang="original">
<![CDATA[ 테크놀로지가 발달하면서 모든 영역에서 테크놀로지의 능력이 중요해지고 있다. 컴퓨터 교육이 급속도로확산되면서 IT 강국인 국내에서도 컴퓨터 교육을 정규교과에 반영하고자 하는 노력이 최근 시작되었으나 아직  교육 흐름이 기존의 정보 활용 교육을 벗어나고있지 못하거나 단순한 소프트웨어 교육으로 한정되고있는 실정이다. 이에 최근 컴퓨터 교육과 관련된  세계적 흐름을 파악하고 국내 컴퓨터 교육이 당면해 있는문제점을 분석하였다. 또한, 정규 교과로 제시된 영국과 미국의 컴퓨터 교육을 비교 연구하여 방향성을 제시하고자 하였다. 특히 기존의 STEM 교육에 창의성의 더하기 위해 광의 의미의 Art를 더해 STEAM 융합교육을시도하는 것처럼 컴퓨터적 사고(Computational Thinking)에 창의성을    있는 방법으로 디자인사고(Design Thinking)과 융합하고 직접 만들면서 디자인 사고를 직접 실천하여 배우는 메이커 운동(Maker Movement)을 교육에 접목하는 방법 등을 적용한 컴퓨터 교육 방법론을 제시하였다.  방법론을 토대로 컴퓨터적 사고를 향상시키기 위한 디자인적 사고를 적용한 컴퓨터 교육 방법을 제시하고 이를  가지 관점에서 초등학교에게 적용하고 결과를 분석하여 초등학교컴퓨터 교육에 적합한 디자인 사고가 적용된 창의적 컴퓨터 융합교육 방향을 제안하였다. ]]>
</abstract>
<abstract lang="english">
<![CDATA[ Ever since the technology has developed, its ability is suitably significant in almost every field. Even in Republic of Korea, a powerful country of the IT industry, the movement of adapting computer education into regular curriculum has recently started. However, yet the educational trends are still situated in the application of information or limited in software education. Therefore, analysis of world-class computer education and problems in Korean computer education were implied. In addition, the study of comparing the United Kingdom and the United States’ computer education was to suggest direction in computer education. Especially it was aiming for method of computer education including Maker Movement, method of applying creativity to computational thinking over fusion of design thinking and direct practice of design thinking, like attempting Art to STEAM convergence education in broad sense of meaning. Based on this method, it was implied the method of computer education applicate design thinking for expansion of computational thinking and proposed the educational direction of creative computer convergence education in elementary schools, from the analyzed conclusion drawn by three individual aspects of the application in Korean elementary schools. ]]>
</abstract>
</abstract-group>
<fpage>455</fpage>
<lpage>467</lpage>
<doi/>
<uci>G704-001533.2015.21.1.044</uci>
<citation-count>18</citation-count>
<url>
<![CDATA[ https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART001974776 ]]>
</url>
<verified>Y</verified>
</articleInfo>
</record>
<record>
<journalInfo>
<journal-name>한국심리학회지: 소비자·광고</journal-name>
<publisher-name>한국소비자·광고심리학회</publisher-name>
<pub-year>2002</pub-year>
<pub-mon>11</pub-mon>
<volume>3</volume>
<issue>2</issue>
</journalInfo>
<articleInfo article-id="ART000877529">
<article-categories>심리과학</article-categories>
<article-regularity>Y</article-regularity>
<title-group>
<article-title lang="original">
<![CDATA[ 컴퓨터 호오도의 결정요인에 관한 연구:컴퓨터 이미지와 감정 경험을 중심으로 ]]>
</article-title>
<article-title lang="foreign">
<![CDATA[ The Determinants of Computer Attitude: The Effects of Computer-images and Emotional Experiences ]]>
</article-title>
<article-title lang="english">
<![CDATA[ The Determinants of Computer Attitude: The Effects of Computer-images and Emotional Experiences ]]>
</article-title>
</title-group>
<author-group>
<author>성영신(고려대학교)</author>
<author>박은아(광운대학교)</author>
<author>연세대(손영숙)</author>
</author-group>
<abstract-group>
<abstract lang="original"/>
</abstract-group>
<fpage>111</fpage>
<lpage>139</lpage>
<doi/>
<uci>G704-001017.2002.3.2.003</uci>
<citation-count>2</citation-count>
<url>
<![CDATA[ https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART000877529 ]]>
</url>
<verified>N</verified>
</articleInfo>
</record>
<record>
<journalInfo>
<journal-name>인문과학</journal-name>
<publisher-name>인문학연구원</publisher-name>
<pub-year>2003</pub-year>
<pub-mon>12</pub-mon>
<volume>85</volume>
<issue/>
</journalInfo>
<articleInfo article-id="ART001634276">
<article-categories>기타인문학</article-categories>
<article-regularity>Y</article-regularity>
<title-group>
<article-title lang="original">
<![CDATA[ 컴퓨터 문학과 컴퓨터 게임 ]]>
</article-title>
</title-group>
<author-group>
<author>최유찬(연세대학교)</author>
</author-group>
<abstract-group>
<abstract lang="original"/>
</abstract-group>
<fpage>1</fpage>
<lpage>22</lpage>
<doi/>
<uci>G704-SER000014478.2003.85..006</uci>
<citation-count>0</citation-count>
<url>
<![CDATA[ https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART001634276 ]]>
</url>
<verified>N</verified>
</articleInfo>
</record>
<record>
<journalInfo>
<journal-name>Annals of Occupational and Environmental Medicine</journal-name>
<publisher-name>대한직업환경의학회</publisher-name>
<pub-year>2004</pub-year>
<pub-mon>09</pub-mon>
<volume>16</volume>
<issue>3</issue>
</journalInfo>
<articleInfo article-id="ART001130369">
<article-categories>예방의학</article-categories>
<article-regularity>Y</article-regularity>
<title-group>
<article-title lang="original">
<![CDATA[ 컴퓨터의 종류가 컴퓨터 신경행동검사에 미치는 영향 ]]>
</article-title>
<article-title lang="foreign">
<![CDATA[ Effect of the Type of Computer on Computerized Neurobehavioral Performance Tests ]]>
</article-title>
<article-title lang="english">
<![CDATA[ Effect of the Type of Computer on Computerized Neurobehavioral Performance Tests ]]>
</article-title>
</title-group>
<author-group>
<author>김규태(영남대학교)</author>
<author>김창윤(영남대학교)</author>
<author>사공준(영남대학교)</author>
</author-group>
<abstract-group>
<abstract lang="original"/>
</abstract-group>
<fpage>276</fpage>
<lpage>286</lpage>
<doi/>
<uci>G704-000627.2004.16.3.001</uci>
<citation-count>4</citation-count>
<url>
<![CDATA[ https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART001130369 ]]>
</url>
<verified>N</verified>
</articleInfo>
</record>
<record>
<journalInfo>
<journal-name>정보교육학회논문지</journal-name>
<publisher-name>한국정보교육학회</publisher-name>
<pub-year>2004</pub-year>
<pub-mon>09</pub-mon>
<volume>8</volume>
<issue>3</issue>
</journalInfo>
<articleInfo article-id="ART000960654">
<article-categories>컴퓨터교육학</article-categories>
<article-regularity>Y</article-regularity>
<title-group>
<article-title lang="original">
<![CDATA[ 컴퓨터 소양 능력 신장을 위한 교육용 컴퓨터 게임에 관한 연구 ]]>
</article-title>
<article-title lang="foreign">
<![CDATA[ A Study of Educational Computer Games for Computer Literacy ]]>
</article-title>
<article-title lang="english">
<![CDATA[ A Study of Educational Computer Games for Computer Literacy ]]>
</article-title>
</title-group>
<author-group>
<author>김철(광주교육대학교)</author>
</author-group>
<abstract-group>
<abstract lang="original">
<![CDATA[  논문에서는 광주광역시 교육청 산하에서 사용되는 컴퓨터 교과서의 교육과정에 따라 재량활동  단계에서 활용되는 컴퓨터 소양을 위한 단원을 타교과서와 함께 분석하여 학습 방법  내용을 비교하였다. 컴퓨터 소양을 위한 단원의 학습 방법을 분석하여 컴퓨터 교육을 위한 여러 교육 방법  교육용 컴퓨터 게임을 통한 컴퓨터 소양 능력의 신장이 가능한지 지도해보고 적용 결과를 분석하여 초등학교의 컴퓨터 소양 교육에 교육용 컴퓨터 게임이 기여할  있는 가능성을 찾고자 하였다. 학생들의 컴퓨터 소양 능력 능력을 신장시키기 위해 교육용 게임을 활용하여 컴퓨터 수업을 진행한 결과 대부분의 학생들이 일반 수업보다 재미있어 했으며 적극적인 참여로 일반 수업 방법보다 훨씬  효과적인 결과를 얻을  있었다. 따라서 교육용 컴퓨터 게임을 정보 활용능력을 키우고 문제해결력을 키워주는 방향으로 활용하면 정보화 시대의 지식기반 사회에 부합하는 교육에 기여할 것으로 판단된다. ]]>
</abstract>
<abstract lang="english">
<![CDATA[ In this paper, via analysis a education method of chapter for computer basic knowledge, whether educational computer game one of various education methods is able to extend computer basic knowledge, we taught and analyzed applied result, then we wanted to find possibility that educational computer games is possible to be contributed in computer education of elementary school. For extending of computer literacy of student, we did computer class with educational game. As a result, we could got a more effective outcome that student felt a fun and participated in class more active than normal class. Therefore, If we will use educational computer games to aim to raise abilities of computer literacy and problem solving that will be contributed in education which is coincided with knowledge basis society of informational period. ]]>
</abstract>
</abstract-group>
<fpage>397</fpage>
<lpage>404</lpage>
<doi/>
<uci>G704-000854.2004.8.3.003</uci>
<citation-count>3</citation-count>
<url>
<![CDATA[ https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART000960654 ]]>
</url>
<verified>N</verified>
</articleInfo>
</record>
<record>
<journalInfo>
<journal-name>Child Health Nursing Research</journal-name>
<publisher-name>한국아동간호학회</publisher-name>
<pub-year>2005</pub-year>
<pub-mon>04</pub-mon>
<volume>11</volume>
<issue>2</issue>
</journalInfo>
<articleInfo article-id="ART001150875">
<article-categories>간호학</article-categories>
<article-regularity>Y</article-regularity>
<title-group>
<article-title lang="original">
<![CDATA[ 컴퓨터 중독과 비중독 청소년의 컴퓨터 단말기(VDT) 자각증상 비교연구 ]]>
</article-title>
<article-title lang="foreign">
<![CDATA[ A Study on the Comparison of Video Display Terminal(VDT) Subjective Symptoms for Computer-addicte dand Non-addicted Adolescents ]]>
</article-title>
<article-title lang="english">
<![CDATA[ A Study on the Comparison of Video Display Terminal(VDT) Subjective Symptoms for Computer-addicte dand Non-addicted Adolescents ]]>
</article-title>
</title-group>
<author-group>
<author>김진이(배재대학교)</author>
<author>조결자(경희대학교)</author>
</author-group>
<abstract-group>
<abstract lang="original"/>
<abstract lang="english">
<![CDATA[ Purpose: The purpose of this study was to compare subjective symptoms of VDT between computer-addicted and non-addicted adolescents. Method: A descriptive survey design was used and 646 students in one middle and two high schools were selected as participants. Result: The VDT subjective symptoms and degree of severity differed according to whether the students were computer-addicted or not, and in all symptoms, general, musculoskeletal, eye and mental, the mean score for subjective symptoms was higher in the addicted group than in the non-addicted group. The score for VDT subjective symptoms was highest in the addicted group for girls and students who were not healthy. The most frequent physical symptom reported by students who visited the school health room for a health problem after using the computer was headache. The most frequent type of treatment at the school health room was treatment of the symptom. Conclusions: This study suggests that students must acquire correct habits in computer use and be careful not to be addicted to the computer in order to avoid VDT syndrome. For this, educational authorities should develop computer-related health education programs and start the programs from the lower grades of elementary school. ]]>
</abstract>
</abstract-group>
<fpage>159</fpage>
<lpage>166</lpage>
<doi/>
<uci>G704-001009.2005.11.2.010</uci>
<citation-count>4</citation-count>
<url>
<![CDATA[ https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART001150875 ]]>
</url>
<verified>N</verified>
</articleInfo>
</record>
<record>
<journalInfo>
<journal-name>중등교육연구</journal-name>
<publisher-name>사범대학부속중등교육연구소</publisher-name>
<pub-year>2005</pub-year>
<pub-mon>12</pub-mon>
<volume>53</volume>
<issue>3</issue>
</journalInfo>
<articleInfo article-id="ART000980151">
<article-categories>교육학</article-categories>
<article-regularity>Y</article-regularity>
<title-group>
<article-title lang="original">
<![CDATA[ 컴퓨터교육과정을 중심으로  교육용 컴퓨터 모델 연구 ]]>
</article-title>
<article-title lang="foreign">
<![CDATA[ A Study of Educational Computer Models based on the Computer Curriculum ]]>
</article-title>
<article-title lang="english">
<![CDATA[ A Study of Educational Computer Models based on the Computer Curriculum ]]>
</article-title>
</title-group>
<author-group>
<author>김성식(한국교원대학교)</author>
<author>이영준(한국교원대학교)</author>
<author>한건우(한국교원대학교)</author>
<author>임진숙(사동중학교)</author>
</author-group>
<abstract-group>
<abstract lang="original">
<![CDATA[ 컴퓨터 관련 기술이 급속하게 발전하고 응용 소프트웨어가 보다 고사양의 컴퓨터를 요구함에 따라 교육정보화 사업 초기에 보급된 교육용 컴퓨터는 노후화되어 교육에 활용하기 힘든 실정이다. 이러한 저성능 컴퓨터를 교체하거나 신규 보급하는데 막대한 비용이 소요될 뿐만 아니라 교육용 컴퓨터의 보급(신규  교체)의 기준이 없어 교육정보화 정책을 추진하는데 많은 어려움을 겪고 있다.  연구의 목적은 학교급별, 전공별 교육에 적합한 교육용 컴퓨터 모델을 개발하여 적정 사양의 교육용 컴퓨터를 보급할  있는 기준을 마련하고 나아가 컴퓨터 활용 교육의 질적 효과를 높이고자 하는  있다. 이에 따라 초·중등학교의 교육용 컴퓨터 보급  활용 현황을 조사하고 분석하였으며, 컴퓨터 관련 교육과정과 교과서를 분석하여 학교급별, 전공별 특성을 고려한 교육용 컴퓨터의 적정 기능을 도출하였다. 이를 기반으로 교육용 컴퓨터 모델을 일반교육용과 전문교육용의  가지 형태로 정의하였다.  연구의 결과를 통해 컴퓨터 활용 교육을 위한 교육용 컴퓨터 보급 기준과 저성능 컴퓨터의 교체 기준을 제시하였으며, 교육용 컴퓨터 보급 정책의 개선 방안에 대해 논의하였다. ]]>
</abstract>
<abstract lang="english">
<![CDATA[ Computer technology is developing rapidly and application software requires a more powerful computer. Due to the poor performance of educational computers supplied in the early stage of educational information infrastructure construction, those computers are not suitable for educational purpose. It will cost much to replace or to upgrade the computers. Since there is no standard for educational computers, the local office of education is suffering with an educational information infrastructure policy. This paper proposes a standard for educational computers based on the computer curriculum. This will improve the quality of ICT education. We analyzed capacity and utilization of the education computers in elementary schools and secondary schools and deduced guidelines of the educational computer based on the computer curriculum. Two types of educational computer models are proposed. One is a general computer model and the other is an expert computer model. The proposed standard for educational computers will help in making supplement and replacement policy decision of the educational computers. ]]>
</abstract>
</abstract-group>
<fpage>201</fpage>
<lpage>230</lpage>
<doi/>
<uci>G704-001585.2005.53.3.003</uci>
<citation-count>0</citation-count>
<url>
<![CDATA[ https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART000980151 ]]>
</url>
<verified>N</verified>
</articleInfo>
</record>
<record>
<journalInfo>
<journal-name>컴퓨터교육학회 논문지</journal-name>
<publisher-name>한국컴퓨터교육학회</publisher-name>
<pub-year>2006</pub-year>
<pub-mon>03</pub-mon>
<volume>9</volume>
<issue>2</issue>
</journalInfo>
<articleInfo article-id="ART001003771">
<article-categories>교육학</article-categories>
<article-regularity>Y</article-regularity>
<title-group>
<article-title lang="original">
<![CDATA[ 컴퓨터과학교육을 위한 중학교 컴퓨터교육과정 연구 ]]>
</article-title>
<article-title lang="foreign">
<![CDATA[ A Study on Computer Education Curriculum in Middle School for Computer Science Education ]]>
</article-title>
<article-title lang="english">
<![CDATA[ A Study on Computer Education Curriculum in Middle School for Computer Science Education ]]>
</article-title>
</title-group>
<author-group>
<author>박정호(서울디지털대학교)</author>
<author>이태욱(한국교원대학교)</author>
<author>이재운(한국교원대학교)</author>
</author-group>
<abstract-group>
<abstract lang="original">
<![CDATA[ 현재 중학교에서 실시되고 있는 컴퓨터교육은 정보통신기술지침, 교육과정 그리고 관련문헌들을 분석한 결과 교육과정의 계열, 중복 그리고 일관된 체계 부족 등의 문제점이 발견되었고, 학습내용의 대부분이 소프트웨어 기능습득 위주로 편성되어 있어 논리적 사고와 문제해결력을 길러내기가 매우 어렵다. 이에  연구는 중학교 컴퓨터교육과정을 개선하기 위해 컴퓨터과학 요소의 도입이 시급하다고 판단하고 미국의 ACM 컴퓨터과학 교육과정 모델, 플로리다  컴퓨터과학 교육과정 그리고 Unplugged Project  컴퓨터과학 지도 사례를 근거로 기존의 교육과정을 수정보완하여 컴퓨터원리, 알고리즘  프로그래밍이 도입되고 정보윤리영역이 강화된 개선된 컴퓨터교육과정을 제안하였다. ]]>
</abstract>
<abstract lang="english">
<![CDATA[ Computer education currently executed at middle schools showed problems of system of education curriculum, repetition, and lack of consistent system as a result of analyzing index for information and communication technology curriculum, and related literatures, and most of the education contents have difficulty to nurture logic thinking and problem-solving ability since they are composed mainly of software function learning. Concerning this issue, this study suggests an innovated computer education curriculum with reinforced information ethics field with computer principle, algorithm, and programming, in other words, a corrected and supplemented version of former content system based on computer science guidance cases of ACM computer science curriculum model of USA, computer science curriculum of Florida state, and Unplugged Project(http://www.unplugged.canterbury.ac.nz) judging that introduction of computer science factors are desperate to improve computer education curriculum in middle schools. ]]>
</abstract>
</abstract-group>
<fpage>37</fpage>
<lpage>46</lpage>
<doi/>
<uci>G704-001447.2006.9.2.004</uci>
<citation-count>8</citation-count>
<url>
<![CDATA[ https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART001003771 ]]>
</url>
<verified>N</verified>
</articleInfo>
</record>
<record>
<journalInfo>
<journal-name>정보교육학회논문지</journal-name>
<publisher-name>한국정보교육학회</publisher-name>
<pub-year>2006</pub-year>
<pub-mon>06</pub-mon>
<volume>10</volume>
<issue>1</issue>
</journalInfo>
<articleInfo article-id="ART001068543">
<article-categories>컴퓨터교육학</article-categories>
<article-regularity>Y</article-regularity>
<title-group>
<article-title lang="original">
<![CDATA[ 컴퓨터과학 도입을 위한 초등컴퓨터 교육과정 연구 ]]>
</article-title>
<article-title lang="foreign">
<![CDATA[ A Study on Computer Education Curriculum in Elementary School for Introducing Computer Science ]]>
</article-title>
<article-title lang="english">
<![CDATA[ A Study on Computer Education Curriculum in Elementary School for Introducing Computer Science ]]>
</article-title>
</title-group>
<author-group>
<author>박정호(서울디지털대학교)</author>
<author>이태욱(한국교원대학교)</author>
<author>오필우(한국교원대학교)</author>
</author-group>
<abstract-group>
<abstract lang="original">
<![CDATA[ 현재 초등학교에서 실시되고 있는 컴퓨터교육은 정보통신기술지침, 교육과정 그리고 관련문헌들을 분석한 결과 교육과정의 계열, 중복 그리고 일관된 체계 부족 등의 문제점이 발견되었고, 학습내용의 대부분이 소프트웨어 기능습득 위주로 편성되어 있어 논리적 사고와 문제해결력을 길러내기가 매우 어렵다. 이에  연구는 초등학교 컴퓨터교육과정을 개선하기 위해 컴퓨터과학 요소의 도입이 시급하다고 판단하고 미국의 ACM교육과정 모델, 테네시 주의 컴퓨터교육과정 그리고 영국의 정보기술교육과정 등의 컴퓨터과학 지도 사례를 근거로 기존 내용체계를 수정보완하여 컴퓨터원리, 알고리즘  프로그래밍이 도입되고 정보윤리영역이 강화된 개선된 컴퓨터교육과정을 제안하였다. ]]>
</abstract>
<abstract lang="english">
<![CDATA[ Computer education currently executed at elementary schools showed problems of system of education curriculum, repetition, and lack of consistent system as a result of analyzing index for information and communication technology, education curriculum, and related literatures, and most of the education contents have difficulty to nurture logic thinking and problem-solving ability since they are composed mainly of software function learning. Concerning this issue, this study suggests an innovated computer education curriculum with reinforced information ethics field with computer principle, algorithm, and programming, in other words, a corrected and supplemented version of former content system based on computer science guidance cases of ACM education curriculum model of USA, computer education curriculum of state Tennessee, and information technology education curriculum of Great Britain judging that introduction of computer science factors are desperate to improve computer education curriculum in elementary schools. ]]>
</abstract>
</abstract-group>
<fpage>25</fpage>
<lpage>35</lpage>
<doi/>
<uci>G704-000854.2006.10.1.007</uci>
<citation-count>4</citation-count>
<url>
<![CDATA[ https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART001068543 ]]>
</url>
<verified>N</verified>
</articleInfo>
</record>
</outputData>
</MetaData>
cs

 

이 데이터는 논문 검색 결과를 나타낸 XML 파일이다. 이제 데이터를 파싱하는 알고리즘에 대해서 해석해보자.

 

XML 데이터 파싱 알고리즘


XML 데이터 파싱의 기본은 태그를 구분한 뒤에 하나씩 while문으로 돌려서 확인하는 것이다. 말만 하면 감이 오질 않으니 하나씩 알아보자.

 

먼저 데이터 파싱을 위한 클래스를 따로 만들어 메인 쓰레드와 다른 공간에서 실행해야 한다. 만약 XML 데이터가 로컬 저장소에 있을 경우에는 같이 해줘도 상관이 없다. 하지만 인터넷 작업을 같이 할 경우에는 안드로이드 정책상 메인 쓰레드와 같이 실행하는 것이 불가능하다. 

 

URL 객체를 생성한 다음에 파싱할 주소를 넣어준 다음, XmlPullParserFactory 객체 생성 후 UTF-8 인코딩으로 처리한다. 그냥 예제를 따라하면 속이 편하다. 예제에서는 url 이 파싱할 주소 문자열 이다. 파싱할 주소를 넣을 때 다른 주소로 리데이렉트 된다면, 리다이렉트 된 주소를 입력해 주어야 한다. 원본 주소와 다르면 동작이 되지 않는다.

 

while문 안을 보면 getEventType 결과물을 판별하고 있다. XML 안에 있는 데이터의 타입을 구분하여 문서의 끝이 아니면 계속 분석을 하게 하라는 식이다. XML 문서에는 여러가지 태그가 있는데 문서의 시작과 끝, 시작 태그와 종료 태그 및 텍스트 태그가 있다. 예를 들어 <app> 이라는 단어를 감지했을 경우 이것은 시작 태그로 판단한다. </app> 은 종료 태그로 감지된다. 태그의 분류를 통해 파싱 작업을 수행하는 것이다.

 

하지만 XML 태그는 단순한 구조가 아니다. 태그가 중첩이 되어 있을 수도 있고 양도 적지 않을 것이다. 이것은 boolean을 통해 제어를 했다. 또한 텍스트를 일정한 조건에 맞게 분류하여 정리할 수 있게 했다.

 

마지막으로 위 코드에서 정의는 하지 않았으나 ArrayList 자료형에 결과값을 정리했다. 이것을 사용한 이유는 얼마나 많은 값이 들어올지도 모르고 멀티 쓰레딩을 하지 않기 때문이다. 

 

파싱 후기


데이터 파싱은 쉬운 작업이 결코 아니다. 쉬운 파싱부터 해본 다음에 실전 데이터를 가지고 파싱하는 것이 맞다. XML 데이터를 쉽게 구할 수 있는 곳은 공공데이터포털이다.

 

https://www.data.go.kr/

 

공공데이터 포털

국가에서 보유하고 있는 다양한 데이터를『공공데이터의 제공 및 이용 활성화에 관한 법률(제11956호)』에 따라 개방하여 국민들이 보다 쉽고 용이하게 공유•활용할 수 있도록 공공데이터(Datase

www.data.go.kr

 

데이터 사용 승인을 얻는 것은 어렵지 않으니 실제로 해 보는 것을 추천한다.

 

반응형

'프레임워크 > Android' 카테고리의 다른 글

안드로이드 개발환경 설치하는 법  (0) 2020.07.09