• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the 'License');
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an 'AS IS' BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Size, Level} from '@ohos/hypium'
16import xml from '@ohos.xml'
17import util from '@ohos.util'
18export default function XmlSerializerXmlPullParserTest() {
19describe('XmlSerializerXmlPullParserTest', function () {
20
21    /**
22     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_00100
23     * @tc.name: testSetDeclaration001
24     * @tc.desc: Writes xml declaration with encoding. For example: <?xml version="1.0" encoding="utf-8"?>.
25     * @tc.size: MediumTest
26     * @tc.type: Function
27     * @tc.level: Level 0
28     */
29    it('testSetDeclaration001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
30        var arrayBuffer = new ArrayBuffer(2048);
31        var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
32        thatSer.setDeclaration();
33        var result = '<?xml version="1.0" encoding="utf-8"?>';
34        var view = new Uint8Array(arrayBuffer);
35        var view1 = "";
36        for (var i = 0; i < result.length; ++i) {
37            view1 = view1 + String.fromCodePoint(view[i]);
38        }
39        expect(view1).assertEqual(result);
40    })
41
42    /**
43     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_00200
44     * @tc.name: testSetDeclaration002
45     * @tc.desc: Writes xml declaration with encoding. For example: <?xml version="1.0" encoding="utf-8"?>.
46     * @tc.size: MediumTest
47     * @tc.type: Function
48     * @tc.level: Level 0
49     */
50    it('testSetDeclaration002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
51        var arrayBuffer = new ArrayBuffer(2048);
52        var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
53        thatSer.setDeclaration();
54        var result = '<?xml version="1.0" encoding="utf-8"?>';
55        var view = new Uint8Array(arrayBuffer);
56        var view1 = "";
57        for (var i = 0; i < result.length; ++i) {
58            view1 = view1 + String.fromCodePoint(view[i]);
59        }
60        expect(view1).assertEqual(result);
61    })
62
63    /**
64     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_00300
65     * @tc.name: testSetDeclaration003
66     * @tc.desc: Writes xml declaration with encoding. For example: <?xml version="1.0" encoding="utf-8"?>.
67     * @tc.size: MediumTest
68     * @tc.type: Function
69     * @tc.level: Level 0
70     */
71    it('testSetDeclaration003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
72        var arrayBuffer = new ArrayBuffer(2048);
73        var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
74        thatSer.setDeclaration();
75        var result = '<?xml version="1.0" encoding="utf-8"?>';
76        var view = new Uint8Array(arrayBuffer);
77        var view1 = "";
78        for (var i = 0; i < result.length; ++i) {
79            view1 = view1 + String.fromCodePoint(view[i]);
80        }
81        expect(view1).assertEqual(result);
82    })
83
84    /**
85     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_00400
86     * @tc.name: testSetDeclaration004
87     * @tc.desc: Writes xml declaration with encoding. For example: <?xml version="1.0" encoding="utf-8"?>.
88     * @tc.size: MediumTest
89     * @tc.type: Function
90     * @tc.level: Level 0
91     */
92    it('testSetDeclaration004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
93        var arrayBuffer = new ArrayBuffer(2048);
94        var thatSer = new xml.XmlSerializer(arrayBuffer);
95        thatSer.setDeclaration();
96        var result = '<?xml version="1.0" encoding="utf-8"?>';
97        var view = new Uint8Array(arrayBuffer);
98        var view1 = "";
99        for (var i = 0; i < result.length; ++i) {
100            view1 = view1 + String.fromCodePoint(view[i]);
101        }
102        expect(view1).assertEqual(result);
103    })
104
105    /**
106     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_00500
107     * @tc.name: testSetDeclaration005
108     * @tc.desc: Writes xml declaration with encoding. For example: <?xml version="1.0" encoding="utf-8"?>.
109     * @tc.size: MediumTest
110     * @tc.type: Function
111     * @tc.level: Level 0
112     */
113    it('testSetDeclaration005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
114        var arrayBuffer = new ArrayBuffer(2048);
115        var thatSer = new xml.XmlSerializer(arrayBuffer);
116        thatSer.setDeclaration();
117        var result = '<?xml version="1.0" encoding="utf-8"?>';
118        var view = new Uint8Array(arrayBuffer);
119        var view1 = "";
120        for (var i = 0; i < result.length; ++i) {
121            view1 = view1 + String.fromCodePoint(view[i]);
122        }
123        expect(view1).assertEqual(result);
124    })
125
126    /**
127     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_00600
128     * @tc.name: testStartElement001
129     * @tc.desc: Writes an elemnet start tag with the given name.
130     * @tc.size: MediumTest
131     * @tc.type: Function
132     * @tc.level: Level 0
133     */
134    it('testStartElement001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
135        const myMAX = 2048;
136        var arrayBuffer = new ArrayBuffer(myMAX);
137        var thatSer = new xml.XmlSerializer(arrayBuffer);
138        thatSer.startElement("note1");
139        thatSer.endElement();
140        var result = '<note1/>';
141        var view = new Uint8Array(arrayBuffer);
142        var view1 = "";
143        for (var i = 0; i < result.length; ++i) {
144            view1 = view1 + String.fromCodePoint(view[i]);
145        }
146        expect(view1).assertEqual(result);
147    })
148
149    /**
150     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_00700
151     * @tc.name: testStartElement002
152     * @tc.desc: Writes an elemnet start tag with the given name.
153     * @tc.size: MediumTest
154     * @tc.type: Function
155     * @tc.level: Level 0
156     */
157    it('testStartElement002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
158        const myMAX = 2048;
159        var arrayBuffer = new ArrayBuffer(myMAX);
160        var thatSer = new xml.XmlSerializer(arrayBuffer);
161        thatSer.startElement("note1");
162        thatSer.endElement();
163        thatSer.startElement("note2");
164        thatSer.endElement();
165        var result = '<note1/>\r\n<note2/>';
166        var view = new Uint8Array(arrayBuffer);
167        var view1 = "";
168        for (var i = 0; i < result.length; ++i) {
169            view1 = view1 + String.fromCodePoint(view[i]);
170        }
171        expect(view1).assertEqual(result);
172    })
173
174    /**
175     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_00800
176     * @tc.name: testStartElement003
177     * @tc.desc: Writes an elemnet start tag with the given name.
178     * @tc.size: MediumTest
179     * @tc.type: Function
180     * @tc.level: Level 0
181     */
182    it('testStartElement003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
183        const myMAX = 2048;
184        var arrayBuffer = new ArrayBuffer(myMAX);
185        var thatSer = new xml.XmlSerializer(arrayBuffer);
186        thatSer.startElement("note1");
187        thatSer.startElement("note2");
188        thatSer.endElement();
189        thatSer.endElement();
190        var result = '<note1>\r\n  <note2/>\r\n</note1>';
191        var view = new Uint8Array(arrayBuffer);
192        var view1 = "";
193        for (var i = 0; i < result.length; ++i) {
194            view1 = view1 + String.fromCodePoint(view[i]);
195        }
196        expect(view1).assertEqual(result);
197    })
198
199    /**
200     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_00900
201     * @tc.name: testStartElement004
202     * @tc.desc: Writes an elemnet start tag with the given name.
203     * @tc.size: MediumTest
204     * @tc.type: Function
205     * @tc.level: Level 0
206     */
207    it('testStartElement004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
208        const myMAX = 2048;
209        var arrayBuffer = new ArrayBuffer(myMAX);
210        var thatSer = new xml.XmlSerializer(arrayBuffer);
211        thatSer.startElement("note1");
212        thatSer.startElement("note2");
213        thatSer.startElement("note3");
214        thatSer.endElement();
215        thatSer.endElement();
216        thatSer.endElement();
217        var result = '<note1>\r\n  <note2>\r\n    <note3/>\r\n  </note2>\r\n</note1>';
218        var view = new Uint8Array(arrayBuffer);
219        var view1 = "";
220        for (var i = 0; i < result.length; ++i) {
221            view1 = view1 + String.fromCodePoint(view[i]);
222        }
223        expect(view1).assertEqual(result);
224    })
225
226    /**
227     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_01000
228     * @tc.name: testStartElement005
229     * @tc.desc: Writes an elemnet start tag with the given name.
230     * @tc.size: MediumTest
231     * @tc.type: Function
232     * @tc.level: Level 0
233     */
234    it('testStartElement005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
235        const myMAX = 2048;
236        var arrayBuffer = new ArrayBuffer(myMAX);
237        var thatSer = new xml.XmlSerializer(arrayBuffer);
238        thatSer.startElement("note1");
239        thatSer.startElement("note2");
240        thatSer.endElement();
241        thatSer.startElement("note3");
242        thatSer.endElement();
243        thatSer.endElement();
244        var result = '<note1>\r\n  <note2/>\r\n  <note3/>\r\n</note1>';
245        var view = new Uint8Array(arrayBuffer);
246        var view1 = "";
247        for (var i = 0; i < result.length; ++i) {
248            view1 = view1 + String.fromCodePoint(view[i]);
249        }
250        expect(view1).assertEqual(result);
251    })
252
253    /**
254     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_01100
255     * @tc.name: testSetAttributes001
256     * @tc.desc: Write an attribute.
257     * @tc.size: MediumTest
258     * @tc.type: Function
259     * @tc.level: Level 0
260     */
261    it('testSetAttributes001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
262        const myMAX = 2048;
263        var arrayBuffer = new ArrayBuffer(myMAX);
264        var thatSer = new xml.XmlSerializer(arrayBuffer);
265        thatSer.startElement("note");
266        thatSer.setAttributes("importance1", "high1");
267        thatSer.endElement();
268        var result = '<note importance1="high1"/>';
269        var view = new Uint8Array(arrayBuffer);
270        var view1 = "";
271        for (var i = 0; i < result.length; ++i) {
272            view1 = view1 + String.fromCodePoint(view[i]);
273        }
274        expect(view1).assertEqual(result);
275    })
276
277    /**
278     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_01200
279     * @tc.name: testSetAttributes002
280     * @tc.desc: Write an attribute.
281     * @tc.size: MediumTest
282     * @tc.type: Function
283     * @tc.level: Level 0
284     */
285    it('testSetAttributes002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
286        const myMAX = 2048;
287        var arrayBuffer = new ArrayBuffer(myMAX);
288        var thatSer = new xml.XmlSerializer(arrayBuffer);
289        thatSer.startElement("note");
290        thatSer.setAttributes("importance1", "high1");
291        thatSer.setAttributes("importance2", "high2");
292        thatSer.endElement();
293        var result = '<note importance1="high1" importance2="high2"/>';
294        var view = new Uint8Array(arrayBuffer);
295        var view1 = "";
296        for (var i = 0; i < result.length; ++i) {
297            view1 = view1 + String.fromCodePoint(view[i]);
298        }
299        expect(view1).assertEqual(result);
300    })
301
302    /**
303     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_01300
304     * @tc.name: testSetAttributes003
305     * @tc.desc: Write an attribute.
306     * @tc.size: MediumTest
307     * @tc.type: Function
308     * @tc.level: Level 0
309     */
310    it('testSetAttributes003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
311        const myMAX = 2048;
312        var arrayBuffer = new ArrayBuffer(myMAX);
313        var thatSer = new xml.XmlSerializer(arrayBuffer);
314        thatSer.startElement("note");
315        thatSer.setAttributes("importance1", "high1");
316        thatSer.setAttributes("importance2", "high2");
317        thatSer.setAttributes("importance3", "high3");
318        thatSer.endElement();
319        var result = '<note importance1="high1" importance2="high2" importance3="high3"/>';
320        var view = new Uint8Array(arrayBuffer);
321        var view1 = "";
322        for (var i = 0; i < result.length; ++i) {
323            view1 = view1 + String.fromCodePoint(view[i]);
324        }
325        expect(view1).assertEqual(result);
326    })
327
328    /**
329     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_01400
330     * @tc.name: testSetAttributes004
331     * @tc.desc: Write an attribute.
332     * @tc.size: MediumTest
333     * @tc.type: Function
334     * @tc.level: Level 0
335     */
336    it('testSetAttributes004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
337        const myMAX = 2048;
338        var arrayBuffer = new ArrayBuffer(myMAX);
339        var thatSer = new xml.XmlSerializer(arrayBuffer);
340        thatSer.startElement("note");
341        thatSer.setAttributes("importance1", "high1");
342        thatSer.setAttributes("importance2", "high2");
343        thatSer.setAttributes("importance3", "high3");
344        thatSer.setAttributes("importance4", "high4");
345        thatSer.endElement();
346        var result = '<note importance1="high1" importance2="high2" importance3="high3" importance4="high4"/>';
347        var view = new Uint8Array(arrayBuffer);
348        var view1 = "";
349        for (var i = 0; i < result.length; ++i) {
350            view1 = view1 + String.fromCodePoint(view[i]);
351        }
352        expect(view1).assertEqual(result);
353    })
354
355    /**
356     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_01500
357     * @tc.name: testSetAttributes005
358     * @tc.desc: Write an attribute.
359     * @tc.size: MediumTest
360     * @tc.type: Function
361     * @tc.level: Level 0
362     */
363    it('testSetAttributes005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
364        const myMAX = 2048;
365        var arrayBuffer = new ArrayBuffer(myMAX);
366        var thatSer = new xml.XmlSerializer(arrayBuffer);
367        thatSer.startElement("note");
368        thatSer.setAttributes("importance1", "high1");
369        thatSer.setAttributes("importance2", "high2");
370        thatSer.setAttributes("importance3", "high3");
371        thatSer.setAttributes("importance5", "high5");
372        thatSer.endElement();
373        var result = '<note importance1="high1" importance2="high2" importance3="high3" importance5="high5"/>';
374        var view = new Uint8Array(arrayBuffer);
375        var view1 = "";
376        for (var i = 0; i < result.length; ++i) {
377            view1 = view1 + String.fromCodePoint(view[i]);
378        }
379        expect(view1).assertEqual(result);
380    })
381
382    /**
383     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_01600
384     * @tc.name: testEndElement001
385     * @tc.desc: Writes end tag of the element.
386     * @tc.size: MediumTest
387     * @tc.type: Function
388     * @tc.level: Level 0
389     */
390    it('testEndElement001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
391        const myMAX = 2048;
392        var arrayBuffer = new ArrayBuffer(myMAX);
393        var thatSer = new xml.XmlSerializer(arrayBuffer);
394        thatSer.startElement("note");
395        thatSer.endElement();
396        var result = '<note/>';
397        var view = new Uint8Array(arrayBuffer);
398        var view1 = "";
399        for (var i = 0; i < result.length; ++i) {
400            view1 = view1 + String.fromCodePoint(view[i]);
401        }
402        expect(view1).assertEqual(result);
403    })
404
405    /**
406     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_01700
407     * @tc.name: testEndElement002
408     * @tc.desc: Writes end tag of the element.
409     * @tc.size: MediumTest
410     * @tc.type: Function
411     * @tc.level: Level 0
412     */
413    it('testEndElement002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
414        const myMAX = 2048;
415        var arrayBuffer = new ArrayBuffer(myMAX);
416        var thatSer = new xml.XmlSerializer(arrayBuffer);
417        thatSer.startElement("note");
418        thatSer.setAttributes("importance", "high");
419        thatSer.endElement();
420        var result = '<note importance="high"/>';
421        var view = new Uint8Array(arrayBuffer);
422        var view1 = "";
423        for (var i = 0; i < result.length; ++i) {
424            view1 = view1 + String.fromCodePoint(view[i]);
425        }
426        expect(view1).assertEqual(result);
427    })
428
429    /**
430     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_01800
431     * @tc.name: testEndElement003
432     * @tc.desc: Writes end tag of the element.
433     * @tc.size: MediumTest
434     * @tc.type: Function
435     * @tc.level: Level 0
436     */
437    it('testEndElement003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
438        const myMAX = 2048;
439        var arrayBuffer = new ArrayBuffer(myMAX);
440        var thatSer = new xml.XmlSerializer(arrayBuffer);
441        thatSer.startElement("note");
442        thatSer.setAttributes("impo", "hi");
443        thatSer.endElement();
444        var result = '<note impo="hi"/>';
445        var view = new Uint8Array(arrayBuffer);
446        var view1 = "";
447        for (var i = 0; i < result.length; ++i) {
448            view1 = view1 + String.fromCodePoint(view[i]);
449        }
450        expect(view1).assertEqual(result);
451    })
452
453    /**
454     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_01900
455     * @tc.name: testEndElement004
456     * @tc.desc: Writes end tag of the element.
457     * @tc.size: MediumTest
458     * @tc.type: Function
459     * @tc.level: Level 0
460     */
461    it('testEndElement004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
462        const myMAX = 2048;
463        var arrayBuffer = new ArrayBuffer(myMAX);
464        var thatSer = new xml.XmlSerializer(arrayBuffer);
465        thatSer.startElement("note1");
466        thatSer.startElement("note2");
467        thatSer.endElement();
468        thatSer.endElement();
469        var result = '<note1>\r\n  <note2/>\r\n</note1>';
470        var view = new Uint8Array(arrayBuffer);
471        var view1 = "";
472        for (var i = 0; i < result.length; ++i) {
473            view1 = view1 + String.fromCodePoint(view[i]);
474        }
475        expect(view1).assertEqual(result);
476    })
477
478    /**
479     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_02000
480     * @tc.name: testEndElement005
481     * @tc.desc: Writes end tag of the element.
482     * @tc.size: MediumTest
483     * @tc.type: Function
484     * @tc.level: Level 0
485     */
486    it('testEndElement005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
487        const myMAX = 2048;
488        var arrayBuffer = new ArrayBuffer(myMAX);
489        var thatSer = new xml.XmlSerializer(arrayBuffer);
490        thatSer.startElement("note2");
491        thatSer.setAttributes("importance", "high");
492        thatSer.endElement();
493        var result = '<note2 importance="high"/>';
494        var view = new Uint8Array(arrayBuffer);
495        var view1 = "";
496        for (var i = 0; i < result.length; ++i) {
497            view1 = view1 + String.fromCodePoint(view[i]);
498        }
499        expect(view1).assertEqual(result);
500    })
501
502    /**
503     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_02100
504     * @tc.name: testSetText001
505     * @tc.desc: Writes the text.
506     * @tc.size: MediumTest
507     * @tc.type: Function
508     * @tc.level: Level 0
509     */
510    it('testSetText001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
511        const myMAX = 2048;
512        var arrayBuffer = new ArrayBuffer(myMAX);
513        var thatSer = new xml.XmlSerializer(arrayBuffer);
514        thatSer.startElement("note");
515        thatSer.setAttributes("importance", "high");
516        thatSer.setText("Happy1");
517        thatSer.endElement();
518        var result = '<note importance="high">Happy1</note>';
519        var view = new Uint8Array(arrayBuffer);
520        var view1 = "";
521        for (var i = 0; i < result.length; ++i) {
522            view1 = view1 + String.fromCodePoint(view[i]);
523        }
524        expect(view1).assertEqual(result);
525    })
526
527    /**
528     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_02200
529     * @tc.name: testSetText002
530     * @tc.desc: Writes the text.
531     * @tc.size: MediumTest
532     * @tc.type: Function
533     * @tc.level: Level 0
534     */
535    it('testSetText002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
536        const myMAX = 2048;
537        var arrayBuffer = new ArrayBuffer(myMAX);
538        var thatSer = new xml.XmlSerializer(arrayBuffer);
539        thatSer.startElement("note");
540        thatSer.setAttributes("importance", "high");
541        thatSer.setText("Happy2");
542        thatSer.endElement();
543        var result = '<note importance="high">Happy2</note>';
544        var view = new Uint8Array(arrayBuffer);
545        var view1 = "";
546        for (var i = 0; i < result.length; ++i) {
547            view1 = view1 + String.fromCodePoint(view[i]);
548        }
549        expect(view1).assertEqual(result);
550    })
551
552    /**
553     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_02300
554     * @tc.name: testSetText003
555     * @tc.desc: Writes the text.
556     * @tc.size: MediumTest
557     * @tc.type: Function
558     * @tc.level: Level 0
559     */
560    it('testSetText003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, function () {
561        const myMAX = 2048;
562        var arrayBuffer = new ArrayBuffer(myMAX);
563        var thatSer = new xml.XmlSerializer(arrayBuffer);
564        thatSer.startElement("note");
565        thatSer.setAttributes("importance", "high");
566        thatSer.setText("Happy3");
567        thatSer.endElement();
568        var result = '<note importance="high">Happy3</note>';
569        var view = new Uint8Array(arrayBuffer);
570        var view1 = "";
571        for (var i = 0; i < result.length; ++i) {
572            view1 = view1 + String.fromCodePoint(view[i]);
573        }
574        expect(view1).assertEqual(result);
575    })
576
577    /**
578     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_02400
579     * @tc.name: testSetText004
580     * @tc.desc: Writes the text.
581     * @tc.size: MediumTest
582     * @tc.type: Function
583     * @tc.level: Level 1
584     */
585    it('testSetText004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
586        const myMAX = 2048;
587        var arrayBuffer = new ArrayBuffer(myMAX);
588        var thatSer = new xml.XmlSerializer(arrayBuffer);
589        thatSer.startElement("note");
590        thatSer.setAttributes("importance", "high");
591        thatSer.setText("Happy4");
592        thatSer.endElement();
593        var result = '<note importance="high">Happy4</note>';
594        var view = new Uint8Array(arrayBuffer);
595        var view1 = "";
596        for (var i = 0; i < result.length; ++i) {
597            view1 = view1 + String.fromCodePoint(view[i]);
598        }
599        expect(view1).assertEqual(result);
600    })
601
602    /**
603     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_02500
604     * @tc.name: testSetText005
605     * @tc.desc: Writes the text.
606     * @tc.size: MediumTest
607     * @tc.type: Function
608     * @tc.level: Level 1
609     */
610    it('testSetText005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
611        const myMAX = 2048;
612        var arrayBuffer = new ArrayBuffer(myMAX);
613        var thatSer = new xml.XmlSerializer(arrayBuffer);
614        thatSer.startElement("note");
615        thatSer.setAttributes("importance", "high");
616        thatSer.setText("Happy5");
617        thatSer.endElement();
618        var result = '<note importance="high">Happy5</note>';
619        var view = new Uint8Array(arrayBuffer);
620        var view1 = "";
621        for (var i = 0; i < result.length; ++i) {
622            view1 = view1 + String.fromCodePoint(view[i]);
623        }
624        expect(view1).assertEqual(result);
625    })
626
627    /**
628     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_02600
629     * @tc.name: testAddEmptyElement001
630     * @tc.desc: Add an empty element.
631     * @tc.size: MediumTest
632     * @tc.type: Function
633     * @tc.level: Level 1
634     */
635    it('testAddEmptyElement001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
636        const myMAX = 2048;
637        var arrayBuffer = new ArrayBuffer(myMAX);
638        var thatSer = new xml.XmlSerializer(arrayBuffer);
639        thatSer.startElement("note");
640        thatSer.addEmptyElement("a");
641        thatSer.endElement();
642        var result = '<note>\r\n  <a/>\r\n</note>';
643        var view = new Uint8Array(arrayBuffer);
644        var view1 = "";
645        for (var i = 0; i < result.length; ++i) {
646            view1 = view1 + String.fromCodePoint(view[i]);
647        }
648        expect(view1).assertEqual(result);
649    })
650
651    /**
652     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_02700
653     * @tc.name: testAddEmptyElement002
654     * @tc.desc: Add an empty element.
655     * @tc.size: MediumTest
656     * @tc.type: Function
657     * @tc.level: Level 1
658     */
659    it('testAddEmptyElement002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
660        const myMAX = 2048;
661        var arrayBuffer = new ArrayBuffer(myMAX);
662        var thatSer = new xml.XmlSerializer(arrayBuffer);
663        thatSer.startElement("note");
664        thatSer.endElement();
665        thatSer.addEmptyElement("b");
666        var result = '<note/>\r\n<b/>';
667        var view = new Uint8Array(arrayBuffer);
668        var view1 = "";
669        for (var i = 0; i < result.length; ++i) {
670            view1 = view1 + String.fromCodePoint(view[i]);
671        }
672        expect(view1).assertEqual(result);
673    })
674
675    /**
676     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_02800
677     * @tc.name: testAddEmptyElement003
678     * @tc.desc: Add an empty element.
679     * @tc.size: MediumTest
680     * @tc.type: Function
681     * @tc.level: Level 1
682     */
683    it('testAddEmptyElement003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
684        const myMAX = 2048;
685        var arrayBuffer = new ArrayBuffer(myMAX);
686        var thatSer = new xml.XmlSerializer(arrayBuffer);
687        thatSer.addEmptyElement("c");
688        thatSer.startElement("note");
689        thatSer.endElement();
690        var result = '<c/>\r\n<note/>';
691        var view = new Uint8Array(arrayBuffer);
692        var view1 = "";
693        for (var i = 0; i < result.length; ++i) {
694            view1 = view1 + String.fromCodePoint(view[i]);
695        }
696        expect(view1).assertEqual(result);
697    })
698
699    /**
700     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_02900
701     * @tc.name: testAddEmptyElement004
702     * @tc.desc: Add an empty element.
703     * @tc.size: MediumTest
704     * @tc.type: Function
705     * @tc.level: Level 1
706     */
707    it('testAddEmptyElement004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
708        const myMAX = 2048;
709        var arrayBuffer = new ArrayBuffer(myMAX);
710        var thatSer = new xml.XmlSerializer(arrayBuffer);
711        thatSer.addEmptyElement("d");
712        var result = '<d/>';
713        var view = new Uint8Array(arrayBuffer);
714        var view1 = "";
715        for (var i = 0; i < result.length; ++i) {
716            view1 = view1 + String.fromCodePoint(view[i]);
717        }
718        expect(view1).assertEqual(result);
719    })
720
721    /**
722     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_03000
723     * @tc.name: testAddEmptyElement005
724     * @tc.desc: Add an empty element.
725     * @tc.size: MediumTest
726     * @tc.type: Function
727     * @tc.level: Level 1
728     */
729    it('testAddEmptyElement005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
730        const myMAX = 2048;
731        var arrayBuffer = new ArrayBuffer(myMAX);
732        var thatSer = new xml.XmlSerializer(arrayBuffer);
733        thatSer.startElement("note");
734        thatSer.addEmptyElement("c");
735        thatSer.addEmptyElement("d");
736        thatSer.endElement();
737        var result = '<note>\r\n  <c/>\r\n  <d/>\r\n</note>';
738        var view = new Uint8Array(arrayBuffer);
739        var view1 = "";
740        for (var i = 0; i < result.length; ++i) {
741            view1 = view1 + String.fromCodePoint(view[i]);
742        }
743        expect(view1).assertEqual(result);
744    })
745
746    /**
747     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_03100
748     * @tc.name: testSetNamespace001
749     * @tc.desc: Writes the namespace of the current element tag.
750     * @tc.size: MediumTest
751     * @tc.type: Function
752     * @tc.level: Level 1
753     */
754    it('testSetNamespace001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
755        const myMAX = 2048;
756        var arrayBuffer = new ArrayBuffer(myMAX);
757        var thatSer = new xml.XmlSerializer(arrayBuffer);
758        thatSer.setDeclaration();
759        thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
760        thatSer.startElement("note");
761        thatSer.endElement();
762        var result = '<?xml version="1.0" encoding="utf-8"?>\r\n<h:note xmlns:h="http://www.w3.org/TR/html4/"/>';
763        var view = new Uint8Array(arrayBuffer);
764        var view1 = "";
765        for (var i = 0; i < result.length; ++i) {
766            view1 = view1 + String.fromCodePoint(view[i]);
767        }
768        expect(view1).assertEqual(result);
769    })
770
771    /**
772     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_03200
773     * @tc.name: testSetNamespace002
774     * @tc.desc: Writes the namespace of the current element tag.
775     * @tc.size: MediumTest
776     * @tc.type: Function
777     * @tc.level: Level 1
778     */
779    it('testSetNamespace002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
780        const myMAX = 2048;
781        var arrayBuffer = new ArrayBuffer(myMAX);
782        var thatSer = new xml.XmlSerializer(arrayBuffer);
783        thatSer.setDeclaration();
784        thatSer.setNamespace("b", "http://www.w3.org/TR/html4/");
785        thatSer.startElement("note");
786        thatSer.endElement();
787        var result = '<?xml version="1.0" encoding="utf-8"?>\r\n<b:note xmlns:b="http://www.w3.org/TR/html4/"/>';
788        var view = new Uint8Array(arrayBuffer);
789        var view1 = "";
790        for (var i = 0; i < result.length; ++i) {
791            view1 = view1 + String.fromCodePoint(view[i]);
792        }
793        expect(view1).assertEqual(result);
794    })
795
796    /**
797     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_03300
798     * @tc.name: testSetNamespace003
799     * @tc.desc: Writes the namespace of the current element tag.
800     * @tc.size: MediumTest
801     * @tc.type: Function
802     * @tc.level: Level 1
803     */
804    it('testSetNamespace003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
805        const myMAX = 2048;
806        var arrayBuffer = new ArrayBuffer(myMAX);
807        var thatSer = new xml.XmlSerializer(arrayBuffer);
808        thatSer.setDeclaration();
809        thatSer.setNamespace("h", "http://www.111/");
810        thatSer.startElement("note");
811        thatSer.endElement();
812        var result = '<?xml version="1.0" encoding="utf-8"?>\r\n<h:note xmlns:h="http://www.111/"/>';
813        var view = new Uint8Array(arrayBuffer);
814        var view1 = "";
815        for (var i = 0; i < result.length; ++i) {
816            view1 = view1 + String.fromCodePoint(view[i]);
817        }
818        expect(view1).assertEqual(result);
819    })
820
821    /**
822     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_03400
823     * @tc.name: testSetNamespace004
824     * @tc.desc: Writes the namespace of the current element tag.
825     * @tc.size: MediumTest
826     * @tc.type: Function
827     * @tc.level: Level 1
828     */
829    it('testSetNamespace004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
830        const myMAX = 2048;
831        var arrayBuffer = new ArrayBuffer(myMAX);
832        var thatSer = new xml.XmlSerializer(arrayBuffer);
833        thatSer.setDeclaration();
834        thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
835        thatSer.startElement("note1");
836        thatSer.startElement("note2");
837        thatSer.endElement();
838        thatSer.endElement();
839        var result = '<?xml version="1.0" encoding="utf-8"?>\r\n<h:note1 xmlns:h="http://www.w3.org/TR/html4/">' +
840        '\r\n  <h:note2/>\r\n</h:note1>';
841        var view = new Uint8Array(arrayBuffer);
842        var view1 = "";
843        for (var i = 0; i < result.length; ++i) {
844            view1 = view1 + String.fromCodePoint(view[i]);
845        }
846        expect(view1).assertEqual(result);
847    })
848
849    /**
850     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_03500
851     * @tc.name: testSetNamespace005
852     * @tc.desc: Writes the namespace of the current element tag.
853     * @tc.size: MediumTest
854     * @tc.type: Function
855     * @tc.level: Level 1
856     */
857    it('testSetNamespace005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
858        const myMAX = 2048;
859        var arrayBuffer = new ArrayBuffer(myMAX);
860        var thatSer = new xml.XmlSerializer(arrayBuffer);
861        thatSer.setDeclaration();
862        thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
863        thatSer.startElement("note1");
864        thatSer.startElement("note2");
865        thatSer.endElement();
866        thatSer.endElement();
867        var result = '<?xml version="1.0" encoding="utf-8"?>\r\n<h:note1 xmlns:h="http://www.w3.org/TR/html4/">' +
868        '\r\n  <h:note2/>\r\n</h:note1>';
869        var view = new Uint8Array(arrayBuffer);
870        var view1 = "";
871        for (var i = 0; i < result.length; ++i) {
872            view1 = view1 + String.fromCodePoint(view[i]);
873        }
874        expect(view1).assertEqual(result);
875    })
876
877    /**
878     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_03600
879     * @tc.name: testSetComment001
880     * @tc.desc: Writes the comment.
881     * @tc.size: MediumTest
882     * @tc.type: Function
883     * @tc.level: Level 1
884     */
885    it('testSetComment001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
886        const myMAX = 2048;
887        var arrayBuffer = new ArrayBuffer(myMAX);
888        var thatSer = new xml.XmlSerializer(arrayBuffer);
889        thatSer.startElement("note");
890        thatSer.setComment("Hi!");
891        thatSer.endElement();
892        var result = '<note>\r\n  <!--Hi!-->\r\n</note>';
893        var view = new Uint8Array(arrayBuffer);
894        var view1 = "";
895        for (var i = 0; i < result.length; ++i) {
896            view1 = view1 + String.fromCodePoint(view[i]);
897        }
898        expect(view1).assertEqual(result);
899    })
900
901    /**
902     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_03700
903     * @tc.name: testSetComment002
904     * @tc.desc: Writes the comment.
905     * @tc.size: MediumTest
906     * @tc.type: Function
907     * @tc.level: Level 1
908     */
909    it('testSetComment002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
910        const myMAX = 2048;
911        var arrayBuffer = new ArrayBuffer(myMAX);
912        var thatSer = new xml.XmlSerializer(arrayBuffer);
913        thatSer.startElement("note");
914        thatSer.setComment("Hello, World!");
915        thatSer.endElement();
916        var result = '<note>\r\n  <!--Hello, World!-->\r\n</note>';
917        var view = new Uint8Array(arrayBuffer);
918        var view1 = "";
919        for (var i = 0; i < result.length; ++i) {
920            view1 = view1 + String.fromCodePoint(view[i]);
921        }
922        expect(view1).assertEqual(result);
923    })
924
925    /**
926     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_03800
927     * @tc.name: testSetComment003
928     * @tc.desc: Writes the comment.
929     * @tc.size: MediumTest
930     * @tc.type: Function
931     * @tc.level: Level 1
932     */
933    it('testSetComment003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
934        const myMAX = 2048;
935        var arrayBuffer = new ArrayBuffer(myMAX);
936        var thatSer = new xml.XmlSerializer(arrayBuffer);
937        thatSer.setComment("Hello, World!");
938        var result = '<!--Hello, World!-->';
939        var view = new Uint8Array(arrayBuffer);
940        var view1 = "";
941        for (var i = 0; i < result.length; ++i) {
942            view1 = view1 + String.fromCodePoint(view[i]);
943        }
944        expect(view1).assertEqual(result);
945    })
946
947    /**
948     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_03900
949     * @tc.name: testSetComment004
950     * @tc.desc: Writes the comment.
951     * @tc.size: MediumTest
952     * @tc.type: Function
953     * @tc.level: Level 1
954     */
955    it('testSetComment004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
956        const myMAX = 2048;
957        var arrayBuffer = new ArrayBuffer(myMAX);
958        var thatSer = new xml.XmlSerializer(arrayBuffer);
959        thatSer.setComment("Hello, World!");
960        var result = '<!--Hello, World!-->';
961        var view = new Uint8Array(arrayBuffer);
962        var view1 = "";
963        for (var i = 0; i < result.length; ++i) {
964            view1 = view1 + String.fromCodePoint(view[i]);
965        }
966        expect(view1).assertEqual(result);
967    })
968
969    /**
970     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_04000
971     * @tc.name: testSetComment005
972     * @tc.desc: Writes the comment.
973     * @tc.size: MediumTest
974     * @tc.type: Function
975     * @tc.level: Level 1
976     */
977    it('testSetComment005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
978        const myMAX = 2048;
979        var arrayBuffer = new ArrayBuffer(myMAX);
980        var thatSer = new xml.XmlSerializer(arrayBuffer);
981        thatSer.setComment("Hello, World!");
982        thatSer.startElement("note");
983        thatSer.endElement();
984        var result = '<!--Hello, World!-->\r\n<note/>';
985        var view = new Uint8Array(arrayBuffer);
986        var view1 = "";
987        for (var i = 0; i < result.length; ++i) {
988            view1 = view1 + String.fromCodePoint(view[i]);
989        }
990        expect(view1).assertEqual(result);
991    })
992
993    /**
994     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_04100
995     * @tc.name: testSetDocType001
996     * @tc.desc: Writes the DOCTYPE.
997     * @tc.size: MediumTest
998     * @tc.type: Function
999     * @tc.level: Level 1
1000     */
1001    it('testSetDocType001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1002        const myMAX = 2048;
1003        var arrayBuffer = new ArrayBuffer(myMAX);
1004        var thatSer = new xml.XmlSerializer(arrayBuffer);
1005        thatSer.setDocType('root SYSTEM');
1006        var result = '<!DOCTYPE root SYSTEM>';
1007        var view = new Uint8Array(arrayBuffer);
1008        var view1 = "";
1009        for (var i = 0; i < result.length; ++i) {
1010            view1 = view1 + String.fromCodePoint(view[i]);
1011        }
1012        expect(view1).assertEqual(result);
1013    })
1014
1015    /**
1016     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_04200
1017     * @tc.name: testSetDocType002
1018     * @tc.desc: Writes the DOCTYPE.
1019     * @tc.size: MediumTest
1020     * @tc.type: Function
1021     * @tc.level: Level 1
1022     */
1023    it('testSetDocType002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1024        const myMAX = 2048;
1025        var arrayBuffer = new ArrayBuffer(myMAX);
1026        var thatSer = new xml.XmlSerializer(arrayBuffer);
1027        thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"');
1028        var result = '<!DOCTYPE root SYSTEM "http://www.test.org/test.dtd">';
1029        var view = new Uint8Array(arrayBuffer);
1030        var view1 = "";
1031        for (var i = 0; i < result.length; ++i) {
1032            view1 = view1 + String.fromCodePoint(view[i]);
1033        }
1034        expect(view1).assertEqual(result);
1035    })
1036
1037    /**
1038     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_04300
1039     * @tc.name: testSetDocType003
1040     * @tc.desc: Writes the DOCTYPE.
1041     * @tc.size: MediumTest
1042     * @tc.type: Function
1043     * @tc.level: Level 1
1044     */
1045    it('testSetDocType003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1046        const myMAX = 2048;
1047        var arrayBuffer = new ArrayBuffer(myMAX);
1048        var thatSer = new xml.XmlSerializer(arrayBuffer);
1049        thatSer.startElement("note");
1050        thatSer.endElement();
1051        thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"');
1052        var result = '<note/>\r\n<!DOCTYPE root SYSTEM "http://www.test.org/test.dtd">';
1053        var view = new Uint8Array(arrayBuffer);
1054        var view1 = "";
1055        for (var i = 0; i < result.length; ++i) {
1056            view1 = view1 + String.fromCodePoint(view[i]);
1057        }
1058        expect(view1).assertEqual(result);
1059    })
1060
1061    /**
1062     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_04400
1063     * @tc.name: testSetDocType004
1064     * @tc.desc: Writes the DOCTYPE.
1065     * @tc.size: MediumTest
1066     * @tc.type: Function
1067     * @tc.level: Level 1
1068     */
1069    it('testSetDocType004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1070        const myMAX = 2048;
1071        var arrayBuffer = new ArrayBuffer(myMAX);
1072        var thatSer = new xml.XmlSerializer(arrayBuffer);
1073        thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"');
1074        thatSer.startElement("note");
1075        thatSer.endElement();
1076        var result = '<!DOCTYPE root SYSTEM "http://www.test.org/test.dtd">\r\n<note/>';
1077        var view = new Uint8Array(arrayBuffer);
1078        var view1 = "";
1079        for (var i = 0; i < result.length; ++i) {
1080            view1 = view1 + String.fromCodePoint(view[i]);
1081        }
1082        expect(view1).assertEqual(result);
1083    })
1084
1085    /**
1086     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_04500
1087     * @tc.name: testSetDocType005
1088     * @tc.desc: Writes the DOCTYPE.
1089     * @tc.size: MediumTest
1090     * @tc.type: Function
1091     * @tc.level: Level 1
1092     */
1093    it('testSetDocType005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1094        const myMAX = 2048;
1095        var arrayBuffer = new ArrayBuffer(myMAX);
1096        var thatSer = new xml.XmlSerializer(arrayBuffer);
1097        thatSer.startElement("note");
1098        thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"');
1099        thatSer.endElement();
1100        var result = '<note>\r\n  <!DOCTYPE root SYSTEM "http://www.test.org/test.dtd">\r\n</note>';
1101        var view = new Uint8Array(arrayBuffer);
1102        var view1 = "";
1103        for (var i = 0; i < result.length; ++i) {
1104            view1 = view1 + String.fromCodePoint(view[i]);
1105        }
1106        expect(view1).assertEqual(result);
1107    })
1108
1109    /**
1110     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_04600
1111     * @tc.name: testSetCDATA001
1112     * @tc.desc: Writes the CDATA.
1113     * @tc.size: MediumTest
1114     * @tc.type: Function
1115     * @tc.level: Level 1
1116     */
1117    it('testSetCDATA001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1118        const myMAX = 2048;
1119        var arrayBuffer = new ArrayBuffer(myMAX);
1120        var thatSer = new xml.XmlSerializer(arrayBuffer);
1121        thatSer.setCDATA('root SYSTEM')
1122        var result = '<![CDATA[root SYSTEM]]>';
1123        var view = new Uint8Array(arrayBuffer);
1124        var view1 = "";
1125        for (var i = 0; i < result.length; ++i) {
1126            view1 = view1 + String.fromCodePoint(view[i]);
1127        }
1128        expect(view1).assertEqual(result);
1129    })
1130
1131    /**
1132     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_04700
1133     * @tc.name: testSetCDATA002
1134     * @tc.desc: Writes the CDATA.
1135     * @tc.size: MediumTest
1136     * @tc.type: Function
1137     * @tc.level: Level 1
1138     */
1139    it('testSetCDATA002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1140        const myMAX = 2048;
1141        var arrayBuffer = new ArrayBuffer(myMAX);
1142        var thatSer = new xml.XmlSerializer(arrayBuffer);
1143        thatSer.setCDATA('root SYSTEM "http://www.test.org/test.dtd"')
1144        var result = '<![CDATA[root SYSTEM "http://www.test.org/test.dtd"]]>';
1145        var view = new Uint8Array(arrayBuffer);
1146        var view1 = "";
1147        for (var i = 0; i < result.length; ++i) {
1148            view1 = view1 + String.fromCodePoint(view[i]);
1149        }
1150        expect(view1).assertEqual(result);
1151    })
1152
1153    /**
1154     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_04800
1155     * @tc.name: testSetCDATA003
1156     * @tc.desc: Writes the CDATA.
1157     * @tc.size: MediumTest
1158     * @tc.type: Function
1159     * @tc.level: Level 1
1160     */
1161    it('testSetCDATA003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1162        const myMAX = 2048;
1163        var arrayBuffer = new ArrayBuffer(myMAX);
1164        var thatSer = new xml.XmlSerializer(arrayBuffer);
1165        thatSer.startElement("note");
1166        thatSer.endElement();
1167        thatSer.setCDATA('root SYSTEM "http://www.test.org/test.dtd"')
1168        var result = '<note/>\r\n<![CDATA[root SYSTEM "http://www.test.org/test.dtd"]]>';
1169        var view = new Uint8Array(arrayBuffer);
1170        var view1 = "";
1171        for (var i = 0; i < result.length; ++i) {
1172            view1 = view1 + String.fromCodePoint(view[i]);
1173        }
1174        expect(view1).assertEqual(result);
1175    })
1176
1177    /**
1178     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_04900
1179     * @tc.name: testSetCDATA004
1180     * @tc.desc: Writes the CDATA.
1181     * @tc.size: MediumTest
1182     * @tc.type: Function
1183     * @tc.level: Level 1
1184     */
1185    it('testSetCDATA004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1186        const myMAX = 2048;
1187        var arrayBuffer = new ArrayBuffer(myMAX);
1188        var thatSer = new xml.XmlSerializer(arrayBuffer);
1189        thatSer.setCDATA('root SYSTEM "http://www.test.org/test.dtd"')
1190        thatSer.startElement("note");
1191        thatSer.endElement();
1192        var result = '<![CDATA[root SYSTEM "http://www.test.org/test.dtd"]]>\r\n<note/>';
1193        var view = new Uint8Array(arrayBuffer);
1194        var view1 = "";
1195        for (var i = 0; i < result.length; ++i) {
1196            view1 = view1 + String.fromCodePoint(view[i]);
1197        }
1198        expect(view1).assertEqual(result);
1199    })
1200
1201    /**
1202     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_05000
1203     * @tc.name: testSetCDATA005
1204     * @tc.desc: Writes the CDATA.
1205     * @tc.size: MediumTest
1206     * @tc.type: Function
1207     * @tc.level: Level 1
1208     */
1209    it('testSetCDATA005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1210        const myMAX = 2048;
1211        var arrayBuffer = new ArrayBuffer(myMAX);
1212        var thatSer = new xml.XmlSerializer(arrayBuffer);
1213        thatSer.startElement("note");
1214        thatSer.setCDATA('root SYSTEM "http://www.test.org/test.dtd"')
1215        thatSer.endElement();
1216        var result = '<note>\r\n  <![CDATA[root SYSTEM "http://www.test.org/test.dtd"]]>\r\n</note>';
1217        var view = new Uint8Array(arrayBuffer);
1218        var view1 = "";
1219        for (var i = 0; i < result.length; ++i) {
1220            view1 = view1 + String.fromCodePoint(view[i]);
1221        }
1222        expect(view1).assertEqual(result);
1223    })
1224
1225    /**
1226     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_05100
1227     * @tc.name: testParse001
1228     * @tc.desc: Starts parsing the XML file.
1229     * @tc.size: MediumTest
1230     * @tc.type: Function
1231     * @tc.level: Level 1
1232     */
1233    it('testParse001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1234        var strXml =
1235            '<?xml version="1.0" encoding="utf-8"?>' +
1236            '<!DOCTYPE note [\n<!ENTITY foo "baa">]>' +
1237            '<note importance="high" logged="true">' +
1238            '    <![CDATA[\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\n]]>' +
1239            '    <!--Hello, World!-->' +
1240            '    <company>John &amp; Hans</company>' +
1241            '    <title>Happy</title>' +
1242            '    <title>Happy</title>' +
1243            '    <lens>Work</lens>' +
1244            '    <lens>Play</lens>' +
1245            '    <?go there?>' +
1246            '    <a><b/></a>' +
1247            '    <h:table xmlns:h="http://www.w3.org/TR/html4/">' +
1248            '        <h:tr>' +
1249            '            <h:td>Apples</h:td>' +
1250            '            <h:td>Bananas</h:td>' +
1251            '        </h:tr>' +
1252            '    </h:table>' +
1253            '</note>';
1254        let textEncoder = new util.TextEncoder();
1255        let arrbuffer = textEncoder.encodeInto(strXml);
1256        let that = new xml.XmlPullParser(arrbuffer.buffer, 'UTF-8');
1257        var str = '';
1258        function func2(name, value){
1259            str += name+':'+value;
1260            return true;
1261        }
1262        var options = {supportDoctype:true, ignoreNameSpace:true, attributeValueCallbackFunction:func2}
1263        that.parse(options);
1264        var str1= 'importance:highlogged:truexmlns:h:http://www.w3.org/TR/html4/';
1265        expect(str).assertEqual(str1);
1266    })
1267
1268    /**
1269     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_05200
1270     * @tc.name: testParse002
1271     * @tc.desc: Starts parsing the XML file.
1272     * @tc.size: MediumTest
1273     * @tc.type: Function
1274     * @tc.level: Level 1
1275     */
1276    it('testParse002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1277        var strXml =
1278            '<?xml version="1.0" encoding="utf-8"?>' +
1279            '<!DOCTYPE note [\n<!ENTITY foo "baa">]>' +
1280            '<note importance="high" logged="true">' +
1281            '    <![CDATA[\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\n]]>' +
1282            '    <!--Hello, World!-->' +
1283            '    <company>John &amp; Hans</company>' +
1284            '    <title>Happy</title>' +
1285            '    <title>Happy</title>' +
1286            '    <lens>Work</lens>' +
1287            '    <lens>Play</lens>' +
1288            '    <?go there?>' +
1289            '    <a><b/></a>' +
1290            '    <h:table xmlns:h="http://www.w3.org/TR/html4/">' +
1291            '        <h:tr>' +
1292            '            <h:td>Apples</h:td>' +
1293            '            <h:td>Bananas</h:td>' +
1294            '        </h:tr>' +
1295            '    </h:table>' +
1296            '</note>';
1297        let textEncoder = new util.TextEncoder();
1298        let arrbuffer = textEncoder.encodeInto(strXml);
1299        let that = new xml.XmlPullParser(arrbuffer.buffer);
1300        var str1 = '';
1301        function func1(name, value){
1302            str1 += name + value + ' ';
1303            return true;
1304        }
1305        var options = {supportDoctype:true, ignoreNameSpace:true, tagValueCallbackFunction:func1}
1306        that.parse(options);
1307        var str3 = '  note [\n<!ENTITY foo "baa">] note      ' +
1308            '\\r\\nfuncrion matchwo(a,6)\\r\\n{\\r\\nreturn 1;\\r\\n}\\r\\n      Hello, World!      company John ' +
1309            '& Hans company      title Happy title      title Happy title      lens Work lens      ' +
1310            'lens Play lens      go there      a b b a      h:table          h:tr              h:td Apples h:td' +
1311            '              h:td Bananas h:td          h:tr      h:table note  ';
1312        expect(str1).assertEqual(str3);
1313    })
1314
1315    /**
1316     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_05300
1317     * @tc.name: testParse003
1318     * @tc.desc: Starts parsing the XML file.
1319     * @tc.size: MediumTest
1320     * @tc.type: Function
1321     * @tc.level: Level 1
1322     */
1323    it('testParse003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1324        let strXml =
1325        '<?xml version="1.0" encoding="utf-8"?>' +
1326        '<note importance="high" logged="true">' +
1327        '    <title>Happy</title>' +
1328        '    <todo>Work</todo>' +
1329        '    <todo>Play</todo>' +
1330        '</note>';
1331        let textEncoder = new util.TextEncoder();
1332        let arrbuffer = textEncoder.encodeInto(strXml);
1333        let that = new xml.XmlPullParser(arrbuffer.buffer);
1334        let str = "";
1335        function func(key, value){
1336          str += 'key:' + key + ' value:'+ value.getColumnNumber() + '  ';
1337          return true;
1338        }
1339        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
1340        that.parse(options);
1341        let result = 'key:0 value:1  key:2 value:77  key:10 value:81  key:2 value:88  key:4 value:93  ' +
1342        'key:3 value:101  key:10 value:105  key:2 value:111  key:4 value:115  key:3 value:122  key:10 value:126  ' +
1343        'key:2 value:132  key:4 value:136  key:3 value:143  key:3 value:150  key:1 value:150  ';
1344        expect(str).assertEqual(result);
1345    })
1346
1347    /**
1348     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_05400
1349     * @tc.name: testParse004
1350     * @tc.desc: Starts parsing the XML file.
1351     * @tc.size: MediumTest
1352     * @tc.type: Function
1353     * @tc.level: Level 1
1354     */
1355    it('testParse004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1356        let strXml =
1357        '<?xml version="1.0" encoding="utf-8"?>' +
1358        '<note importance="high" logged="true">' +
1359        '    <title>Happy</title>' +
1360        '    <todo>Work</todo>' +
1361        '    <todo>Play</todo>' +
1362        '</note>';
1363        let textEncoder = new util.TextEncoder();
1364        let arrbuffer = textEncoder.encodeInto(strXml);
1365        let that = new xml.XmlPullParser(arrbuffer.buffer);
1366        let str = "";
1367        function func(key, value){
1368          str += 'key:' + key + ' value:'+ value.getDepth() + '  ';
1369          return true;
1370        }
1371        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
1372        that.parse(options);
1373        let result = 'key:0 value:0  key:2 value:1  key:10 value:1  key:2 value:2  key:4 value:2  key:3 value:2  ' +
1374        'key:10 value:1  key:2 value:2  key:4 value:2  key:3 value:2  key:10 value:1  key:2 value:2  ' +
1375        'key:4 value:2  key:3 value:2  key:3 value:1  key:1 value:0  ';
1376        expect(str).assertEqual(result);
1377    })
1378
1379    /**
1380     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_05500
1381     * @tc.name: testParse005
1382     * @tc.desc: Starts parsing the XML file.
1383     * @tc.size: MediumTest
1384     * @tc.type: Function
1385     * @tc.level: Level 1
1386     */
1387    it('testParse005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1388        let strXml =
1389        '<?xml version="1.0" encoding="utf-8"?>' +
1390        '<note importance="high" logged="true">' +
1391        '    <title>Happy</title>' +
1392        '    <todo>Work</todo>' +
1393        '    <todo>Play</todo>' +
1394        '</note>';
1395        let textEncoder = new util.TextEncoder();
1396        let arrbuffer = textEncoder.encodeInto(strXml);
1397        let that = new xml.XmlPullParser(arrbuffer.buffer);
1398        let str = "";
1399        function func(key, value){
1400          str += 'key:'+ key + ' value:' + value.getLineNumber() + '  ';
1401          return true;
1402        }
1403        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
1404        that.parse(options);
1405        let result = 'key:0 value:1  key:2 value:1  key:10 value:1  key:2 value:1  key:4 value:1  key:3 value:1  ' +
1406        'key:10 value:1  key:2 value:1  key:4 value:1  key:3 value:1  key:10 value:1  key:2 value:1  ' +
1407        'key:4 value:1  key:3 value:1  key:3 value:1  key:1 value:1  ';
1408        expect(str).assertEqual(result);
1409    })
1410
1411    /**
1412     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_05600
1413     * @tc.name: testParse006
1414     * @tc.desc: Starts parsing the XML file.
1415     * @tc.size: MediumTest
1416     * @tc.type: Function
1417     * @tc.level: Level 1
1418     */
1419    it('testParse006', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1420        let strXml =
1421        '<?xml version="1.0" encoding="utf-8"?>' +
1422        '<note importance="high" logged="true">' +
1423        '    <title>Happy</title>' +
1424        '    <todo>Work</todo>' +
1425        '    <todo>Play</todo>' +
1426        '</note>';
1427        let textEncoder = new util.TextEncoder();
1428        let arrbuffer = textEncoder.encodeInto(strXml);
1429        let that = new xml.XmlPullParser(arrbuffer.buffer);
1430        let str = "";
1431        function func(key, value){
1432          str += 'key:' + key + ' value:' + value.getName() + '  ';
1433          return true;
1434        }
1435        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
1436        that.parse(options);
1437        let result = 'key:0 value:  key:2 value:note  key:10 value:  key:2 value:title  key:4 value:  ' +
1438        'key:3 value:title  key:10 value:  key:2 value:todo  key:4 value:  key:3 value:todo  key:10 value:  ' +
1439        'key:2 value:todo  key:4 value:  key:3 value:todo  key:3 value:note  key:1 value:  ';
1440        expect(str).assertEqual(result);
1441    })
1442
1443    /**
1444     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_05700
1445     * @tc.name: testParse007
1446     * @tc.desc: Starts parsing the XML file.
1447     * @tc.size: MediumTest
1448     * @tc.type: Function
1449     * @tc.level: Level 1
1450     */
1451    it('testParse007', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1452        let strXml =
1453        '<?xml version="1.0" encoding="utf-8"?>' +
1454        '<note importance="high" logged="true">' +
1455        '    <title>Happy</title>' +
1456        '    <todo>Work</todo>' +
1457        '    <todo>Play</todo>' +
1458        '</note>';
1459        let textEncoder = new util.TextEncoder();
1460        let arrbuffer = textEncoder.encodeInto(strXml);
1461        let that = new xml.XmlPullParser(arrbuffer.buffer);
1462        let str = "";
1463        function func(key, value){
1464          str += 'key:' + key + ' value:'+ value.getNamespace() + '  ';
1465          return true;
1466        }
1467        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
1468        that.parse(options);
1469        let result = 'key:0 value:  key:2 value:  key:10 value:  key:2 value:  key:4 value:  key:3 value:  ' +
1470        'key:10 value:  key:2 value:  key:4 value:  key:3 value:  key:10 value:  key:2 value:  key:4 value:  ' +
1471        'key:3 value:  key:3 value:  key:1 value:  ';
1472        expect(str).assertEqual(result);
1473    })
1474
1475    /**
1476     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_05800
1477     * @tc.name: testParse008
1478     * @tc.desc: Starts parsing the XML file.
1479     * @tc.size: MediumTest
1480     * @tc.type: Function
1481     * @tc.level: Level 1
1482     */
1483    it('testParse008', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1484        let strXml =
1485        '<?xml version="1.0" encoding="utf-8"?>' +
1486        '<note importance="high" logged="true">' +
1487        '    <title>Happy</title>' +
1488        '    <todo>Work</todo>' +
1489        '    <todo>Play</todo>' +
1490        '</note>';
1491        let textEncoder = new util.TextEncoder();
1492        let arrbuffer = textEncoder.encodeInto(strXml);
1493        let that = new xml.XmlPullParser(arrbuffer.buffer);
1494        let str = "";
1495        function func(key, value){
1496          str += 'key:'+key+' value:'+ value.getPrefix() + '  ';
1497          return true;
1498        }
1499        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
1500        that.parse(options);
1501        let result = 'key:0 value:  key:2 value:  key:10 value:  key:2 value:  key:4 value:  key:3 value:  ' +
1502        'key:10 value:  key:2 value:  key:4 value:  key:3 value:  key:10 value:  key:2 value:  key:4 value:  ' +
1503        'key:3 value:  key:3 value:  key:1 value:  ';
1504        expect(str).assertEqual(result);
1505    })
1506
1507    /**
1508     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_05900
1509     * @tc.name: testParse009
1510     * @tc.desc: Starts parsing the XML file.
1511     * @tc.size: MediumTest
1512     * @tc.type: Function
1513     * @tc.level: Level 1
1514     */
1515    it('testParse009', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1516        let strXml =
1517        '<?xml version="1.0" encoding="utf-8"?>' +
1518        '<note importance="high" logged="true">' +
1519        '    <title>Happy</title>' +
1520        '    <todo>Work</todo>' +
1521        '    <todo>Play</todo>' +
1522        '</note>';
1523        let textEncoder = new util.TextEncoder();
1524        let arrbuffer = textEncoder.encodeInto(strXml);
1525        let that = new xml.XmlPullParser(arrbuffer.buffer);
1526        let str = "";
1527        function func(key, value){
1528          str += 'key:' + key +' value:' + value.getText() + '  ';
1529          return true;
1530        }
1531        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
1532        that.parse(options);
1533        let result = 'key:0 value:  key:2 value:  key:10 value:      key:2 value:  key:4 value:Happy  ' +
1534        'key:3 value:  key:10 value:      key:2 value:  key:4 value:Work  key:3 value:  key:10 value:      ' +
1535        'key:2 value:  key:4 value:Play  key:3 value:  key:3 value:  key:1 value:  ';
1536        expect(str).assertEqual(result);
1537    })
1538
1539    /**
1540     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_06000
1541     * @tc.name: testParse010
1542     * @tc.desc: Starts parsing the XML file.
1543     * @tc.size: MediumTest
1544     * @tc.type: Function
1545     * @tc.level: Level 1
1546     */
1547    it('testParse010', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1548        let strXml =
1549        '<?xml version="1.0" encoding="utf-8"?>' +
1550        '<note importance="high" logged="true">' +
1551        '    <title>Happy</title>' +
1552        '    <todo>Work</todo>' +
1553        '    <todo>Play</todo>' +
1554        '</note>';
1555        let textEncoder = new util.TextEncoder();
1556        let arrbuffer = textEncoder.encodeInto(strXml);
1557        let that = new xml.XmlPullParser(arrbuffer.buffer);
1558        let str = "";
1559        function func(key, value){
1560          str += 'key:' + key +' value:' + value.isEmptyElementTag() + '  ';
1561          return true;
1562        }
1563        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
1564        that.parse(options);
1565        let result = 'key:0 value:false  key:2 value:false  key:10 value:false  key:2 value:false  ' +
1566        'key:4 value:false  key:3 value:false  key:10 value:false  key:2 value:false  key:4 value:false  ' +
1567        'key:3 value:false  key:10 value:false  key:2 value:false  key:4 value:false  key:3 value:false  ' +
1568        'key:3 value:false  key:1 value:false  ';
1569        expect(str).assertEqual(result);
1570    })
1571
1572    /**
1573     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_06100
1574     * @tc.name: testParse011
1575     * @tc.desc: Starts parsing the XML file.
1576     * @tc.size: MediumTest
1577     * @tc.type: Function
1578     * @tc.level: Level 1
1579     */
1580    it('testParse011', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1581        let strXml =
1582        '<?xml version="1.0" encoding="utf-8"?>' +
1583        '<note importance="high" logged="true">' +
1584        '    <title>Happy</title>' +
1585        '    <todo>Work</todo>' +
1586        '    <todo>Play</todo>' +
1587        '</note>';
1588        let textEncoder = new util.TextEncoder();
1589        let arrbuffer = textEncoder.encodeInto(strXml);
1590        let that = new xml.XmlPullParser(arrbuffer.buffer);
1591        let str = "";
1592        function func(key, value){
1593          str += 'key:' + key +' value:' + value.isWhitespace() + '  ';
1594          return true;
1595        }
1596        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
1597        that.parse(options);
1598        let result = 'key:0 value:true  key:2 value:false  key:10 value:true  key:2 value:true  ' +
1599        'key:4 value:false  key:3 value:true  key:10 value:true  key:2 value:true  key:4 value:false  ' +
1600        'key:3 value:true  key:10 value:true  key:2 value:true  key:4 value:false  key:3 value:true  ' +
1601        'key:3 value:true  key:1 value:true  ';
1602        expect(str).assertEqual(result);
1603    })
1604
1605    /**
1606     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_06200
1607     * @tc.name: testParse012
1608     * @tc.desc: Starts parsing the XML file.
1609     * @tc.size: MediumTest
1610     * @tc.type: Function
1611     * @tc.level: Level 1
1612     */
1613    it('testParse012', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1614        let strXml =
1615        '<?xml version="1.0" encoding="utf-8"?>' +
1616        '<note importance="high" logged="true">' +
1617        '    <title>Happy</title>' +
1618        '    <todo>Work</todo>' +
1619        '    <todo>Play</todo>' +
1620        '</note>';
1621        let textEncoder = new util.TextEncoder();
1622        let arrbuffer = textEncoder.encodeInto(strXml);
1623        let that = new xml.XmlPullParser(arrbuffer.buffer);
1624        let str = "";
1625        function func(key, value){
1626          str += 'key:' + key +' value:' + value.getAttributeCount() + '  ';
1627          return true;
1628        }
1629        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
1630        that.parse(options);
1631        let result = 'key:0 value:0  key:2 value:2  key:10 value:0  key:2 value:0  key:4 value:0  ' +
1632        'key:3 value:0  key:10 value:0  key:2 value:0  key:4 value:0  key:3 value:0  key:10 value:0  ' +
1633        'key:2 value:0  key:4 value:0  key:3 value:0  key:3 value:0  key:1 value:0  ';
1634        expect(str).assertEqual(result);
1635    })
1636
1637    /**
1638     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_06300
1639     * @tc.name: testParse013
1640     * @tc.desc: Starts parsing the XML file.
1641     * @tc.size: MediumTest
1642     * @tc.type: Function
1643     * @tc.level: Level 1
1644     */
1645    it('testParse013', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1646        let strXml =
1647          '<?xml version="1.0" encoding="utf-8"?>' +
1648          '<note importance="high" logged="true">' +
1649          '    <title>Happy</title>' +
1650          '    <todo>Work</todo>' +
1651          '    <mess><![CDATA[This is a \r CDATA\n section]]></mess>' +
1652          '    <todo>Play</todo>' +
1653          '</note>';
1654        let textEncoder = new util.TextEncoder();
1655        let arrbuffer = textEncoder.encodeInto(strXml);
1656        let that = new xml.XmlPullParser(arrbuffer.buffer);
1657        let str = "";
1658        function func(key, value){
1659          if ( key === 5) {
1660            str += value.getText();
1661          }
1662          return true;
1663        }
1664        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
1665        that.parse(options);
1666        let result = 'This is a \\r CDATA\\n section';
1667        expect(str).assertEqual(result);
1668    })
1669
1670    /**
1671     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_06400
1672     * @tc.name: testParse014
1673     * @tc.desc: Starts parsing the XML file.
1674     * @tc.size: MediumTest
1675     * @tc.type: Function
1676     * @tc.level: Level 1
1677     */
1678    it('testParse014', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1679        let strXml =
1680          '<?xml version="1.0" encoding="utf-8"?>' +
1681          '<note importance="high" logged="true">' +
1682          '    <title>Hello\rWorld\n</title>' +
1683          '    <todo>Work\r\n</todo>' +
1684          '    <mess><![CDATA[This is a \r\n CDATA section]]></mess>' +
1685          '</note>';
1686        let textEncoder = new util.TextEncoder();
1687        let arrbuffer = textEncoder.encodeInto(strXml);
1688        let that = new xml.XmlPullParser(arrbuffer.buffer);
1689        let str = "";
1690        function func(key, value) {
1691          if (key === 4 || key === 5) {
1692            str += value.getText();
1693          }
1694          return true;
1695        }
1696        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
1697        that.parse(options);
1698        let result = 'Hello\nWorld\nWork\nThis is a \\r\\n CDATA section';
1699        expect(str).assertEqual(result);
1700    })
1701
1702    /**
1703     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_06500
1704     * @tc.name: testParse015
1705     * @tc.desc: Starts parsing the XML file.
1706     * @tc.size: MediumTest
1707     * @tc.type: Function
1708     * @tc.level: Level 1
1709     */
1710    it('testParse015', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1711        let strXml =
1712          '<?xml version="1.0" encoding="utf-8"?>' +
1713          '<note importance="hi&amp;gh" logged="&lt;true">' +
1714          '    <title>Hello&gt;World&apos;</title>' +
1715          '    <todo>Wo&quot;rk</todo>' +
1716          '</note>';
1717        let textEncoder = new util.TextEncoder();
1718        let arrbuffer = textEncoder.encodeInto(strXml);
1719        let that = new xml.XmlPullParser(arrbuffer.buffer);
1720        let strAttr = "";
1721        let str = "";
1722        function funcAttr(name, value) {
1723            strAttr += name + ', ' + value + ' ';
1724            return true;
1725        }
1726        function func(name, value) {
1727            str += name + value + ' ';
1728            return true;
1729        }
1730        let options = {supportDoctype:true, ignoreNameSpace:true, attributeValueCallbackFunction: funcAttr,
1731          tagValueCallbackFunction:func}
1732        that.parse(options);
1733        let result = ' note      title Hello>World\' title      todo Wo"rk todo note  ';
1734        let resAttr = 'importance, hi&gh logged, <true ';
1735        expect(str).assertEqual(result);
1736        expect(strAttr).assertEqual(resAttr);
1737    })
1738
1739    /**
1740     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_06600
1741     * @tc.name: testEventType001
1742     * @tc.desc: Gets the START_DOCUMENT of EventType.
1743     * @tc.size: MediumTest
1744     * @tc.type: Function
1745     * @tc.level: Level 1
1746     */
1747    it('testEventType001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1748        var event = xml.EventType.START_DOCUMENT;
1749        expect(event).assertEqual(0)
1750    })
1751
1752    /**
1753     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_06700
1754     * @tc.name: testEventType002
1755     * @tc.desc: Gets the END_DOCUMENT of EventType.
1756     * @tc.size: MediumTest
1757     * @tc.type: Function
1758     * @tc.level: Level 1
1759     */
1760    it('testEventType002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1761        var event = xml.EventType.END_DOCUMENT;
1762        expect(event).assertEqual(1)
1763    })
1764
1765    /**
1766     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_06800
1767     * @tc.name: testEventType003
1768     * @tc.desc: Gets the START_TAG of EventType.
1769     * @tc.size: MediumTest
1770     * @tc.type: Function
1771     * @tc.level: Level 1
1772     */
1773    it('testEventType003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1774        var event = xml.EventType.START_TAG;
1775        expect(event).assertEqual(2)
1776    })
1777
1778    /**
1779     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_06900
1780     * @tc.name: testEventType004
1781     * @tc.desc: Gets the END_TAG of EventType.
1782     * @tc.size: MediumTest
1783     * @tc.type: Function
1784     * @tc.level: Level 1
1785     */
1786    it('testEventType004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1787        var event = xml.EventType.END_TAG;
1788        expect(event).assertEqual(3)
1789    })
1790
1791    /**
1792     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_07000
1793     * @tc.name: testEventType005
1794     * @tc.desc: Gets the TEXT of EventType.
1795     * @tc.size: MediumTest
1796     * @tc.type: Function
1797     * @tc.level: Level 1
1798     */
1799    it('testEventType005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1800        var event = xml.EventType.TEXT;
1801        expect(event).assertEqual(4)
1802    })
1803
1804    /**
1805     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_07100
1806     * @tc.name: testEventType006
1807     * @tc.desc: Gets the CDSECT of EventType.
1808     * @tc.size: MediumTest
1809     * @tc.type: Function
1810     * @tc.level: Level 1
1811     */
1812    it('testEventType006', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1813        var event = xml.EventType.CDSECT;
1814        expect(event).assertEqual(5)
1815    })
1816
1817    /**
1818     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_07200
1819     * @tc.name: testEventType007
1820     * @tc.desc: Gets the COMMENT of EventType.
1821     * @tc.size: MediumTest
1822     * @tc.type: Function
1823     * @tc.level: Level 1
1824     */
1825    it('testEventType007', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1826        var event = xml.EventType.COMMENT;
1827        expect(event).assertEqual(6)
1828    })
1829
1830    /**
1831     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_07300
1832     * @tc.name: testEventType008
1833     * @tc.desc: Gets the DOCDECL of EventType.
1834     * @tc.size: MediumTest
1835     * @tc.type: Function
1836     * @tc.level: Level 1
1837     */
1838    it('testEventType008', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1839        var event = xml.EventType.DOCDECL;
1840        expect(event).assertEqual(7)
1841    })
1842
1843    /**
1844     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_07400
1845     * @tc.name: testEventType009
1846     * @tc.desc: Gets the INSTRUCTION of EventType.
1847     * @tc.size: MediumTest
1848     * @tc.type: Function
1849     * @tc.level: Level 1
1850     */
1851    it('testEventType009', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1852        var event = xml.EventType.INSTRUCTION;
1853        expect(event).assertEqual(8)
1854    })
1855
1856    /**
1857     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_07500
1858     * @tc.name: testEventType010
1859     * @tc.desc: Gets the ENTITY_REFERENCE of EventType.
1860     * @tc.size: MediumTest
1861     * @tc.type: Function
1862     * @tc.level: Level 1
1863     */
1864    it('testEventType010', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1865        var event = xml.EventType.ENTITY_REFERENCE;
1866        expect(event).assertEqual(9)
1867    })
1868
1869    /**
1870     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_07600
1871     * @tc.name: testEventType011
1872     * @tc.desc: Gets the WHITESPACE of EventType.
1873     * @tc.size: MediumTest
1874     * @tc.type: Function
1875     * @tc.level: Level 1
1876     */
1877    it('testEventType011', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1878        var event = xml.EventType.WHITESPACE;
1879        expect(event).assertEqual(10)
1880    })
1881
1882    /**
1883     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_07700
1884     * @tc.name: testXmlBusinessError001
1885     * @tc.desc: To XML text to JavaScript object.
1886     * @tc.size: MediumTest
1887     * @tc.type: Function
1888     * @tc.level: Level 1
1889     */
1890     it('testXmlBusinessError001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1891        try {
1892            new xml.XmlSerializer(123,"utf-8");
1893        } catch (e) {
1894            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 123 must be object")
1895        }
1896    })
1897
1898    /**
1899     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_07800
1900     * @tc.name: testXmlBusinessError002
1901     * @tc.desc: To XML text to JavaScript object.
1902     * @tc.size: MediumTest
1903     * @tc.type: Function
1904     * @tc.level: Level 1
1905     */
1906    it('testXmlBusinessError002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1907        try {
1908            var arrayBuffer = new ArrayBuffer(2048);
1909            new xml.XmlSerializer(arrayBuffer,123);
1910        } catch (e) {
1911            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 123 must be string")
1912        }
1913    })
1914
1915    /**
1916     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_07900
1917     * @tc.name: testXmlBusinessError003
1918     * @tc.desc: To XML text to JavaScript object.
1919     * @tc.size: MediumTest
1920     * @tc.type: Function
1921     * @tc.level: Level 1
1922     */
1923    it('testXmlBusinessError003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1924        try {
1925            var arrayBuffer = new ArrayBuffer(2048);
1926            var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
1927            thatSer.startElement(111);
1928        } catch (e) {
1929            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 111 must be string")
1930        }
1931    })
1932
1933    /**
1934     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_08000
1935     * @tc.name: testXmlBusinessError004
1936     * @tc.desc: To XML text to JavaScript object.
1937     * @tc.size: MediumTest
1938     * @tc.type: Function
1939     * @tc.level: Level 1
1940     */
1941    it('testXmlBusinessError004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1942        try {
1943            var arrayBuffer = new ArrayBuffer(2048);
1944            var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
1945            thatSer.startElement("note");
1946            thatSer.setAttributes(111, "high1");
1947        } catch (e) {
1948            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 111 must be string")
1949        }
1950    })
1951
1952    /**
1953     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_08100
1954     * @tc.name: testXmlBusinessError005
1955     * @tc.desc: To XML text to JavaScript object.
1956     * @tc.size: MediumTest
1957     * @tc.type: Function
1958     * @tc.level: Level 1
1959     */
1960    it('testXmlBusinessError005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1961        try {
1962            var arrayBuffer = new ArrayBuffer(2048);
1963            var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
1964            thatSer.startElement("note");
1965            thatSer.setAttributes("importance1", 111);
1966        } catch (e) {
1967            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 111 must be string")
1968        }
1969    })
1970
1971    /**
1972     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_08200
1973     * @tc.name: testXmlBusinessError006
1974     * @tc.desc: To XML text to JavaScript object.
1975     * @tc.size: MediumTest
1976     * @tc.type: Function
1977     * @tc.level: Level 1
1978     */
1979    it('testXmlBusinessError006', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
1980        try {
1981            var arrayBuffer = new ArrayBuffer(2048);
1982            var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
1983            thatSer.startElement("note");
1984            thatSer.setAttributes("importance", "high");
1985            thatSer.setText(111);
1986        } catch (e) {
1987            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 111 must be string")
1988        }
1989    })
1990
1991    /**
1992     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_08300
1993     * @tc.name: testXmlBusinessError007
1994     * @tc.desc: To XML text to JavaScript object.
1995     * @tc.size: MediumTest
1996     * @tc.type: Function
1997     * @tc.level: Level 1
1998     */
1999    it('testXmlBusinessError007', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2000        try {
2001            var arrayBuffer = new ArrayBuffer(2048);
2002            var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
2003            thatSer.startElement("note");
2004            thatSer.addEmptyElement(111);
2005        } catch (e) {
2006            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 111 must be string")
2007        }
2008    })
2009
2010    /**
2011     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_08400
2012     * @tc.name: testXmlBusinessError008
2013     * @tc.desc: To XML text to JavaScript object.
2014     * @tc.size: MediumTest
2015     * @tc.type: Function
2016     * @tc.level: Level 1
2017     */
2018    it('testXmlBusinessError008', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2019        try {
2020            var arrayBuffer = new ArrayBuffer(2048);
2021            var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
2022            thatSer.setDeclaration();
2023            thatSer.setNamespace(111, "http://www.w3.org/TR/html4/");
2024        } catch (e) {
2025            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 111 must be string")
2026        }
2027    })
2028
2029    /**
2030     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_08500
2031     * @tc.name: testXmlBusinessError009
2032     * @tc.desc: To XML text to JavaScript object.
2033     * @tc.size: MediumTest
2034     * @tc.type: Function
2035     * @tc.level: Level 1
2036     */
2037    it('testXmlBusinessError009', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2038        try {
2039            var arrayBuffer = new ArrayBuffer(2048);
2040            var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
2041            thatSer.setDeclaration();
2042            thatSer.setNamespace("h", 111);
2043        } catch (e) {
2044            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 111 must be string")
2045        }
2046    })
2047
2048    /**
2049     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_08600
2050     * @tc.name: testXmlBusinessError010
2051     * @tc.desc: To XML text to JavaScript object.
2052     * @tc.size: MediumTest
2053     * @tc.type: Function
2054     * @tc.level: Level 1
2055     */
2056    it('testXmlBusinessError010', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2057        try {
2058            var arrayBuffer = new ArrayBuffer(2048);
2059            var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
2060            thatSer.startElement("note");
2061            thatSer.setComment(111);
2062        } catch (e) {
2063            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 111 must be string")
2064        }
2065    })
2066
2067    /**
2068     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_08700
2069     * @tc.name: testXmlBusinessError011
2070     * @tc.desc: To XML text to JavaScript object.
2071     * @tc.size: MediumTest
2072     * @tc.type: Function
2073     * @tc.level: Level 1
2074     */
2075    it('testXmlBusinessError011', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2076        try {
2077            var arrayBuffer = new ArrayBuffer(2048);
2078            var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
2079            thatSer.setDocType(111);
2080        } catch (e) {
2081            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 111 must be string")
2082        }
2083    })
2084
2085    /**
2086     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_08800
2087     * @tc.name: testXmlBusinessError012
2088     * @tc.desc: To XML text to JavaScript object.
2089     * @tc.size: MediumTest
2090     * @tc.type: Function
2091     * @tc.level: Level 1
2092     */
2093    it('testXmlBusinessError012', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2094        try {
2095            var arrayBuffer = new ArrayBuffer(2048);
2096            var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
2097            thatSer.setCDATA(111)
2098        } catch (e) {
2099            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 111 must be string")
2100        }
2101    })
2102
2103    /**
2104     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_08900
2105     * @tc.name: testXmlBusinessError013
2106     * @tc.desc: To XML text to JavaScript object.
2107     * @tc.size: MediumTest
2108     * @tc.type: Function
2109     * @tc.level: Level 1
2110     */
2111    it('testXmlBusinessError013', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2112        try {
2113            new xml.XmlPullParser(111, 'UTF-8');
2114        } catch (e) {
2115            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 111 must be object")
2116        }
2117    })
2118
2119    /**
2120     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_09000
2121     * @tc.name: testXmlBusinessError014
2122     * @tc.desc: To XML text to JavaScript object.
2123     * @tc.size: MediumTest
2124     * @tc.type: Function
2125     * @tc.level: Level 1
2126     */
2127    it('testXmlBusinessError014', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2128        try {
2129            var arrayBuffer = new ArrayBuffer(2048);
2130            new xml.XmlPullParser(arrayBuffer, 111);
2131        } catch (e) {
2132            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 111 must be string")
2133        }
2134    })
2135
2136    /**
2137     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_09100
2138     * @tc.name: testXmlBusinessError015
2139     * @tc.desc: To XML text to JavaScript object.
2140     * @tc.size: MediumTest
2141     * @tc.type: Function
2142     * @tc.level: Level 1
2143     */
2144    it('testXmlBusinessError015', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2145        try {
2146            var strXml =
2147                '<?xml version="1.0" encoding="utf-8"?>' +
2148                '<!DOCTYPE note [\n<!ENTITY foo "baa">]>' +
2149                '<note importance="high" logged="true">' +
2150                '    <![CDATA[\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\n]]>' +
2151                '    <!--Hello, World!-->' +
2152                '    <company>John &amp; Hans</company>' +
2153                '    <title>Happy</title>' +
2154                '    <title>Happy</title>' +
2155                '    <todo>Work</todo>' +
2156                '    <todo>Play</todo>' +
2157                '    <?go there?>' +
2158                '    <a><b/></a>' +
2159                '    <h:table xmlns:h="http://www.w3.org/TR/html4/">' +
2160                '        <h:tr>' +
2161                '            <h:td>Apples</h:td>' +
2162                '            <h:td>Bananas</h:td>' +
2163                '        </h:tr>' +
2164                '    </h:table>' +
2165                '</note>';
2166            let textEncoder = new util.TextEncoder();
2167            let arrbuffer = textEncoder.encodeInto(strXml);
2168            let that = new xml.XmlPullParser(arrbuffer.buffer, 'UTF-8');
2169            var str1 = '';
2170            function func1(name, value){
2171                str1 += name+':'+value;
2172                return true;
2173            }
2174            var options = 111
2175            that.parse(options);
2176        } catch (e) {
2177            expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 111 must be object")
2178        }
2179    })
2180
2181    /**
2182     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_09200
2183     * @tc.name: testXmlBusinessError016
2184     * @tc.desc: Parsing XML files.
2185     * @tc.size: MediumTest
2186     * @tc.type: Function
2187     * @tc.level: Level 1
2188     */
2189    it('testXmlBusinessError016', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2190        try {
2191            let strXml =
2192                '<?xml version="1.0" encoding="utf-8"?>' +
2193                '<note importance="high" logged="true">' +
2194                '    <!--Hello, World!-->' +
2195                '    <company>John &amp; Hans</company>' +
2196                '    <title>Happy</title>' +
2197                '    <todo>Work</todo>' +
2198                '</note>';
2199            let textEncoder = new util.TextEncoder();
2200            let uint8 = textEncoder.encodeInto(strXml);
2201            let that = new xml.XmlPullParser(uint8, 'UTF-8');
2202            expect().assertFail();
2203        } catch (e) {
2204            expect(e.toString()).assertEqual("Error: Parameter error. The type of Parameter must be ArrayBuffer or " +
2205                                             "DataView.");
2206        }
2207    })
2208
2209    /**
2210     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_09300
2211     * @tc.name: testXmlBusinessError017
2212     * @tc.desc: Writes the text.
2213     * @tc.size: MediumTest
2214     * @tc.type: Function
2215     * @tc.level: Level 1
2216     */
2217    it('testXmlBusinessError017', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2218        try {
2219            const myMAX = 1024;
2220            let arrayBuffer = new ArrayBuffer(myMAX);
2221            let uint = new Uint8Array(arrayBuffer);
2222            let thatSer = new xml.XmlSerializer(uint);
2223            expect().assertFail();
2224        } catch (e) {
2225            expect(e.toString()).assertEqual("Error: Parameter error. The type of Parameter must be ArrayBuffer or " +
2226                                             "DataView.");
2227        }
2228    })
2229
2230    /**
2231     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_09400
2232     * @tc.name: testSetText006
2233     * @tc.desc: Writes the text.
2234     * @tc.size: MediumTest
2235     * @tc.type: Function
2236     * @tc.level: Level 1
2237     */
2238    it('testSetText006', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2239        const myMAX = 1024;
2240        let arrayBuffer = new ArrayBuffer(myMAX);
2241        let thatSer = new xml.XmlSerializer(arrayBuffer);
2242        thatSer.startElement("note");
2243        thatSer.setAttributes("importance", "high");
2244        thatSer.setText("Hello>World");
2245        thatSer.endElement();
2246        let uint8 = new Uint8Array(arrayBuffer);
2247        let result = '<note importance="high">Hello&gt;World</note>';
2248        let view = "";
2249        for (let i = 0; i < result.length; ++i) {
2250            view = view + String.fromCodePoint(uint8[i]);
2251        }
2252        expect(view).assertEqual(result);
2253    })
2254
2255    /**
2256     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_09500
2257     * @tc.name: testSetText007
2258     * @tc.desc: Writes the text.
2259     * @tc.size: MediumTest
2260     * @tc.type: Function
2261     * @tc.level: Level 1
2262     */
2263    it('testSetText007', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2264        const myMAX = 1024;
2265        let arrayBuffer = new ArrayBuffer(myMAX);
2266        let thatSer = new xml.XmlSerializer(arrayBuffer);
2267        thatSer.startElement("note");
2268        thatSer.setAttributes("importance", "high");
2269        thatSer.setText("Hello<World");
2270        thatSer.endElement();
2271        let uint8 = new Uint8Array(arrayBuffer);
2272        let result = '<note importance="high">Hello&lt;World</note>';
2273        let view = "";
2274        for (let i = 0; i < result.length; ++i) {
2275            view = view + String.fromCodePoint(uint8[i]);
2276        }
2277        expect(view).assertEqual(result);
2278    })
2279
2280    /**
2281     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_09600
2282     * @tc.name: testSetText008
2283     * @tc.desc: Writes the text.
2284     * @tc.size: MediumTest
2285     * @tc.type: Function
2286     * @tc.level: Level 1
2287     */
2288    it('testSetText008', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2289        const myMAX = 1024;
2290        let arrayBuffer = new ArrayBuffer(myMAX);
2291        let thatSer = new xml.XmlSerializer(arrayBuffer);
2292        thatSer.startElement("note");
2293        thatSer.setAttributes("importance", "high");
2294        thatSer.setText("Hello&World");
2295        thatSer.endElement();
2296        let uint8 = new Uint8Array(arrayBuffer);
2297        let result = '<note importance="high">Hello&amp;World</note>';
2298        let view = "";
2299        for (let i = 0; i < result.length; ++i) {
2300            view = view + String.fromCodePoint(uint8[i]);
2301        }
2302        expect(view).assertEqual(result);
2303    })
2304
2305    /**
2306     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_09700
2307     * @tc.name: testSetText009
2308     * @tc.desc: Writes the text.
2309     * @tc.size: MediumTest
2310     * @tc.type: Function
2311     * @tc.level: Level 1
2312     */
2313    it('testSetText009', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2314        const myMAX = 1024;
2315        let arrayBuffer = new ArrayBuffer(myMAX);
2316        let thatSer = new xml.XmlSerializer(arrayBuffer);
2317        thatSer.startElement("note");
2318        thatSer.setAttributes("importance", "high");
2319        thatSer.setText("Hello'World");
2320        thatSer.endElement();
2321        let uint8 = new Uint8Array(arrayBuffer);
2322        let result = '<note importance="high">Hello&apos;World</note>';
2323        let view = "";
2324        for (let i = 0; i < result.length; ++i) {
2325            view = view + String.fromCodePoint(uint8[i]);
2326        }
2327        expect(view).assertEqual(result);
2328    })
2329
2330    /**
2331     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_09800
2332     * @tc.name: testSetText010
2333     * @tc.desc: Writes the text.
2334     * @tc.size: MediumTest
2335     * @tc.type: Function
2336     * @tc.level: Level 1
2337     */
2338    it('testSetText010', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2339        const myMAX = 1024;
2340        let arrayBuffer = new ArrayBuffer(myMAX);
2341        let thatSer = new xml.XmlSerializer(arrayBuffer);
2342        thatSer.startElement("note");
2343        thatSer.setAttributes("importance", "high");
2344        thatSer.setText("Hello\"World");
2345        thatSer.endElement();
2346        let uint8 = new Uint8Array(arrayBuffer);
2347        let result = '<note importance="high">Hello&quot;World</note>';
2348        let view = "";
2349        for (let i = 0; i < result.length; ++i) {
2350            view = view + String.fromCodePoint(uint8[i]);
2351        }
2352        expect(view).assertEqual(result);
2353    })
2354
2355    /**
2356     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_09900
2357     * @tc.name: testNodeName001
2358     * @tc.desc: Writes a wrong node name.
2359     * @tc.size: MediumTest
2360     * @tc.type: Function
2361     * @tc.level: Level 1
2362     */
2363    it('testNodeName001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2364        try {
2365            let strXml =
2366              '<?xml version="1.0" encoding="UTF-8"?>' +
2367              '<note importance="high" logged="true">' +
2368              '<company>John &amp; Hans</company>' +
2369              '<tod<xml version="1.0" encoding="UTF-8"?><note importance="high" logged="true"></note>' +
2370              '</note>';
2371            let textec = new util.TextEncoder()
2372            let uint8 = textec.encodeInto(strXml);
2373            let that = new xml.XmlPullParser(uint8.buffer, 'UTF-8');
2374            let str = '';
2375            function func(name, value) {
2376              str += name + value;
2377              return true;
2378            }
2379            let options = { supportDoctype: true, ignoreNameSpace: true, tagValueCallbackFunction: func }
2380            that.parse(options);
2381            expect().assertFail();
2382        } catch (e) {
2383            expect(e.toString()).assertEqual("BusinessError: The node name contains invalid characters: <");
2384            expect(e.code).assertEqual(401);
2385        }
2386    })
2387
2388    /**
2389     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_10000
2390     * @tc.name: testNodeName002
2391     * @tc.desc: Writes a wrong node name.
2392     * @tc.size: MediumTest
2393     * @tc.type: Function
2394     * @tc.level: Level 1
2395     */
2396    it('testNodeName002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2397        try {
2398            let strXml =
2399              '<?xml version="1.0" encoding="UTF-8"?>' +
2400              '<note importance="high" logged="true">' +
2401              '<company>John &amp; Hans</company>' +
2402              '<2todo>work</2todo>' +
2403              '</note>';
2404            let textec = new util.TextEncoder()
2405            let uint8 = textec.encodeInto(strXml);
2406            let that = new xml.XmlPullParser(uint8.buffer, 'UTF-8');
2407            let str = '';
2408            function func(name, value) {
2409              str += name + value;
2410              return true;
2411            }
2412            let options = { supportDoctype: true, ignoreNameSpace: true, tagValueCallbackFunction: func }
2413            that.parse(options);
2414            expect().assertFail();
2415        } catch (e) {
2416            expect(e.toString()).assertEqual("BusinessError: The node name contains invalid characters: 2");
2417            expect(e.code).assertEqual(401);
2418        }
2419    })
2420
2421    /**
2422     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_10100
2423     * @tc.name: testParseXml001
2424     * @tc.desc: Starts parsing the XML file.
2425     * @tc.size: MediumTest
2426     * @tc.type: Function
2427     * @tc.level: Level 1
2428     */
2429    it('testParseXml001', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2430        let strXml =
2431            '<?xml version="1.0" encoding="utf-8"?>' +
2432            '<note importance="high" logged="true">' +
2433            '    <!--Hello, World!-->' +
2434            '    <company>John &amp; Hans</company>' +
2435            '    <lens>Work</lens>' +
2436            '    <h:table xmlns:h="http://www.w3.org/TR/html4/">' +
2437            '        <h:tr>' +
2438            '            <h:td>Apples</h:td>' +
2439            '        </h:tr>' +
2440            '    </h:table>' +
2441            '</note>';
2442        let textEncoder = new util.TextEncoder();
2443        let uint8 = textEncoder.encodeInto(strXml);
2444        let pullParse = new xml.XmlPullParser(uint8.buffer, 'UTF-8');
2445        let result = '';
2446        function func(name, value) {
2447            result += name + ':' + value + ' ';
2448            return true;
2449        }
2450        let options = {supportDoctype:true, ignoreNameSpace:true, attributeValueCallbackFunction:func}
2451        pullParse.parseXml(options);
2452        let str = 'importance:high logged:true xmlns:h:http://www.w3.org/TR/html4/';
2453        expect(result.trim()).assertEqual(str);
2454    })
2455
2456    /**
2457     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_10200
2458     * @tc.name: testParseXml002
2459     * @tc.desc: Starts parsing the XML file.
2460     * @tc.size: MediumTest
2461     * @tc.type: Function
2462     * @tc.level: Level 1
2463     */
2464    it('testParseXml002', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2465        let strXml =
2466            '<?xml version="1.0" encoding="utf-8"?>' +
2467            '<note importance="high" logged="true">' +
2468            '    <![CDATA[funcrion \n matchwo(a,6)]]>' +
2469            '    <!--Hello, World!-->' +
2470            '    <company>John &amp; Hans</company>' +
2471            '    <title>Happy</title>' +
2472            '    <lens>Play</lens>' +
2473            '    <?go there?>' +
2474            '</note>';
2475        let textEncoder = new util.TextEncoder();
2476        let uint8 = textEncoder.encodeInto(strXml);
2477        let pullParse = new xml.XmlPullParser(uint8.buffer);
2478        let result = '';
2479        function func(name, value) {
2480            result += name + value;
2481            return true;
2482        }
2483        let options = {supportDoctype:true, ignoreNameSpace:true, tagValueCallbackFunction:func}
2484        pullParse.parseXml(options);
2485        let str = 'note    funcrion \n matchwo(a,6)    Hello, World!    companyJohn & Hanscompany    ' +
2486                  'titleHappytitle    lensPlaylens    go therenote';
2487        expect(result.trim()).assertEqual(str);
2488    })
2489
2490    /**
2491     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_10300
2492     * @tc.name: testParseXml003
2493     * @tc.desc: Starts parsing the XML file.
2494     * @tc.size: MediumTest
2495     * @tc.type: Function
2496     * @tc.level: Level 1
2497     */
2498    it('testParseXml003', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2499        let strXml =
2500            '<?xml version="1.0" encoding="utf-8"?>' +
2501            '<note importance="high">' +
2502            '    <title>Happy</title>' +
2503            '    <todo>Work</todo>' +
2504            '</note>';
2505        let textEncoder = new util.TextEncoder();
2506        let uint8 = textEncoder.encodeInto(strXml);
2507        let pullParse = new xml.XmlPullParser(uint8.buffer);
2508        let result = '';
2509        function func(key, value) {
2510            result += 'key:' + key + ' value:'+ value.getColumnNumber() + '  ';
2511            return true;
2512        }
2513        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
2514        pullParse.parseXml(options);
2515        let str = 'key:0 value:1  key:2 value:63  key:10 value:67  key:2 value:74  key:4 value:79  ' +
2516                  'key:3 value:87  key:10 value:91  key:2 value:97  key:4 value:101  key:3 value:108  ' +
2517                  'key:3 value:115  key:1 value:115';
2518        expect(result.trim()).assertEqual(str);
2519    })
2520
2521    /**
2522     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_10400
2523     * @tc.name: testParseXml004
2524     * @tc.desc: Starts parsing the XML file.
2525     * @tc.size: MediumTest
2526     * @tc.type: Function
2527     * @tc.level: Level 1
2528     */
2529    it('testParseXml004', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2530        let strXml =
2531            '<?xml version="1.0" encoding="utf-8"?>' +
2532            '<note importance="high" logged="true">' +
2533            '    <title>Happy</title>' +
2534            '    <todo>Work</todo>' +
2535            '    <todo>Play</todo>' +
2536            '</note>';
2537        let textEncoder = new util.TextEncoder();
2538        let uint8 = textEncoder.encodeInto(strXml);
2539        let pullParse = new xml.XmlPullParser(uint8.buffer);
2540        let result = '';
2541        function func(key, value) {
2542            result += 'key:' + key + ' value:'+ value.getDepth() + '  ';
2543            return true;
2544        }
2545        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
2546        pullParse.parseXml(options);
2547        let str = 'key:0 value:0  key:2 value:1  key:10 value:1  key:2 value:2  key:4 value:2  ' +
2548                  'key:3 value:2  key:10 value:1  key:2 value:2  key:4 value:2  key:3 value:2  ' +
2549                  'key:10 value:1  key:2 value:2  key:4 value:2  key:3 value:2  key:3 value:1  key:1 value:0';
2550        expect(result.trim()).assertEqual(str);
2551    })
2552
2553    /**
2554     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_10500
2555     * @tc.name: testParseXml005
2556     * @tc.desc: Starts parsing the XML file.
2557     * @tc.size: MediumTest
2558     * @tc.type: Function
2559     * @tc.level: Level 1
2560     */
2561    it('testParseXml005', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2562        let strXml =
2563            '<?xml version="1.0" encoding="utf-8"?>' +
2564            '<note importance="high" logged="true">' +
2565            '    <title>Happy</title>' +
2566            '    <todo>Work</todo>' +
2567            '    <todo>Play</todo>' +
2568            '</note>';
2569        let textEncoder = new util.TextEncoder();
2570        let uin8 = textEncoder.encodeInto(strXml);
2571        let pullParse = new xml.XmlPullParser(uin8.buffer);
2572        let result = '';
2573        function func(key, value) {
2574            result += 'key:'+ key + ' value:' + value.getLineNumber() + '  ';
2575            return true;
2576        }
2577        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
2578        pullParse.parseXml(options);
2579        let str = 'key:0 value:1  key:2 value:1  key:10 value:1  key:2 value:1  key:4 value:1  ' +
2580                  'key:3 value:1  key:10 value:1  key:2 value:1  key:4 value:1  key:3 value:1  ' +
2581                  'key:10 value:1  key:2 value:1  key:4 value:1  key:3 value:1  key:3 value:1  key:1 value:1';
2582        expect(result.trim()).assertEqual(str);
2583    })
2584
2585    /**
2586     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_10600
2587     * @tc.name: testParseXml006
2588     * @tc.desc: Starts parsing the XML file.
2589     * @tc.size: MediumTest
2590     * @tc.type: Function
2591     * @tc.level: Level 1
2592     */
2593    it('testParseXml006', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2594        let strXml =
2595            '<?xml version="1.0" encoding="utf-8"?>' +
2596            '<note importance="high">' +
2597            '    <title>Happy</title>' +
2598            '    <todo>Work</todo>' +
2599            '</note>';
2600        let textEncoder = new util.TextEncoder();
2601        let uint8 = textEncoder.encodeInto(strXml);
2602        let pullParse = new xml.XmlPullParser(uint8.buffer);
2603        let result = '';
2604        function func(key, value) {
2605            if (key == xml.EventType.START_TAG || key == xml.EventType.END_TAG) {
2606                result += 'key:' + key + ' value:' + value.getName() + '  ';
2607            }
2608            return true;
2609        }
2610        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
2611        pullParse.parseXml(options);
2612        let str = 'key:2 value:note  key:2 value:title  key:3 value:title  ' +
2613                  'key:2 value:todo  key:3 value:todo  key:3 value:note';
2614        expect(result.trim()).assertEqual(str);
2615    })
2616
2617    /**
2618     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_10700
2619     * @tc.name: testParseXml007
2620     * @tc.desc: Starts parsing the XML file.
2621     * @tc.size: MediumTest
2622     * @tc.type: Function
2623     * @tc.level: Level 1
2624     */
2625    it('testParseXml007', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2626        let strXml =
2627            '<?xml version="1.0" encoding="utf-8"?>' +
2628            '<note importance="high">' +
2629            '<h:table xmlns:h="html4">' +
2630            '<h:tr><h:td>Bananas</h:td></h:tr>' +
2631            '</h:table>' +
2632            '</note>';
2633        let textEncoder = new util.TextEncoder();
2634        let uint8 = textEncoder.encodeInto(strXml);
2635        let pullParse = new xml.XmlPullParser(uint8.buffer);
2636        let result = '';
2637        function func(key, value) {
2638            if (key == xml.EventType.START_TAG || key == xml.EventType.END_TAG) {
2639                result += 'key:' + key + ' value:' + value.getNamespace() + '  ';
2640            }
2641            return true;
2642        }
2643        let options = {supportDoctype:true, ignoreNameSpace:false, tokenValueCallbackFunction:func}
2644        pullParse.parseXml(options);
2645        let str = 'key:2 value:  key:2 value:html4  key:2 value:html4  key:2 value:html4  ' +
2646                  'key:3 value:html4  key:3 value:html4  key:3 value:html4  key:3 value:';
2647        expect(result.trim()).assertEqual(str);
2648    })
2649
2650    /**
2651     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_10800
2652     * @tc.name: testParseXml008
2653     * @tc.desc: Starts parsing the XML file.
2654     * @tc.size: MediumTest
2655     * @tc.type: Function
2656     * @tc.level: Level 1
2657     */
2658    it('testParseXml008', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2659        let strXml =
2660            '<?xml version="1.0" encoding="utf-8"?>' +
2661            '<note importance="high">' +
2662            '<h:table xmlns:h="html4">' +
2663            '<h:tr><h:td>Bananas</h:td></h:tr>' +
2664            '</h:table>' +
2665            '</note>';
2666        let textEncoder = new util.TextEncoder();
2667        let uint8 = textEncoder.encodeInto(strXml);
2668        let pullParse = new xml.XmlPullParser(uint8.buffer);
2669        let result = '';
2670        function func(key, value) {
2671            if (key == xml.EventType.START_TAG || key == xml.EventType.END_TAG) {
2672                result += 'key:' + key + ' value:' + value.getPrefix() + '  ';
2673            }
2674            return true;
2675        }
2676        let options = {supportDoctype:true, ignoreNameSpace:false, tokenValueCallbackFunction:func}
2677        pullParse.parseXml(options);
2678        let str = 'key:2 value:  key:2 value:h  key:2 value:h  key:2 value:h  ' +
2679                  'key:3 value:h  key:3 value:h  key:3 value:h  key:3 value:';
2680        expect(result.trim()).assertEqual(str);
2681    })
2682
2683    /**
2684     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_10900
2685     * @tc.name: testParseXml009
2686     * @tc.desc: Starts parsing he XML file.
2687     * @tc.size: MediumTest
2688     * @tc.type: Function
2689     * @tc.level: Level 1
2690     */
2691    it('testParseXml009', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2692        let strXml =
2693            '<?xml version="1.0" encoding="utf-8"?>' +
2694            '<note importance="high" logged="true">' +
2695            '    <title>Happy</title>' +
2696            '    <todo>Work</todo>' +
2697            '    <todo>Play</todo>' +
2698            '</note>';
2699        let textEncoder = new util.TextEncoder();
2700        let uint8 = textEncoder.encodeInto(strXml);
2701        let pullParse = new xml.XmlPullParser(uint8.buffer);
2702        let result = '';
2703        function func(key, value) {
2704            if (key == xml.EventType.TEXT) {
2705                result += 'key:' + key + ' value:' + value.getText() + '  ';
2706            }
2707            return true;
2708        }
2709        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
2710        pullParse.parseXml(options);
2711        let str = 'key:4 value:Happy  key:4 value:Work  key:4 value:Play';
2712        expect(result.trim()).assertEqual(str);
2713    })
2714
2715    /**
2716     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_11000
2717     * @tc.name: testParseXml010
2718     * @tc.desc: Starts parsing he XML file.
2719     * @tc.size: MediumTest
2720     * @tc.type: Function
2721     * @tc.level: Level 1
2722     */
2723    it('testParseXml010', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2724        let strXml =
2725            '<?xml version="1.0" encoding="utf-8"?>' +
2726            '<note importance="high">' +
2727            '<title/>' +
2728            '<todo>Work</todo>' +
2729            '<todo/>' +
2730            '</note>';
2731        let textEncoder = new util.TextEncoder();
2732        let uint8 = textEncoder.encodeInto(strXml);
2733        let pullParse = new xml.XmlPullParser(uint8.buffer);
2734        let result = '';
2735        function func(key, value) {
2736            if (key == xml.EventType.START_TAG) {
2737                result += 'key:' + key + ' value:' + value.isEmptyElementTag() + '  ';
2738            }
2739            return true;
2740        }
2741        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
2742        pullParse.parseXml(options);
2743        let str = 'key:2 value:false  key:2 value:true  key:2 value:false  key:2 value:true';
2744        expect(result.trim()).assertEqual(str);
2745    })
2746
2747    /**
2748     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_11100
2749     * @tc.name: testParseXml011
2750     * @tc.desc: Starts parsing he XML file.
2751     * @tc.size: MediumTest
2752     * @tc.type: Function
2753     * @tc.level: Level 1
2754     */
2755    it('testParseXml011', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2756        let strXml =
2757            '<?xml version="1.0" encoding="utf-8"?>' +
2758            '<note importance="high" logged="true">' +
2759            '    <title>Happy</title>' +
2760            '    <todo>Work</todo>' +
2761            '    <todo>Play</todo>' +
2762            '</note>';
2763        let textEncoder = new util.TextEncoder();
2764        let uint8 = textEncoder.encodeInto(strXml);
2765        let pullParse = new xml.XmlPullParser(uint8.buffer);
2766        let result = '';
2767        function func(key, value) {
2768            if (key == xml.EventType.START_TAG) {
2769                result += 'key:' + key + ' value:' + value.getAttributeCount() + '  ';
2770            }
2771            return true;
2772        }
2773        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
2774        pullParse.parseXml(options);
2775        let str = 'key:2 value:2  key:2 value:0  key:2 value:0  key:2 value:0';
2776        expect(result.trim()).assertEqual(str);
2777    })
2778
2779    /**
2780     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_11200
2781     * @tc.name: testParseXml012
2782     * @tc.desc: Starts parsing he XML file.
2783     * @tc.size: MediumTest
2784     * @tc.type: Function
2785     * @tc.level: Level 1
2786     */
2787    it('testParseXml012', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2788        let strXml =
2789            '<?xml version="1.0" encoding="utf-8"?>' +
2790            '<note importance="high" logged="true">' +
2791            '    <title>Hello\nWorld</title>' +
2792            '    <todo>Work\n</todo>' +
2793            '    <mess><![CDATA[This is a \n CDATA section]]></mess>' +
2794            '</note>';
2795        let textEncoder = new util.TextEncoder();
2796        let uint8 = textEncoder.encodeInto(strXml);
2797        let pullParse = new xml.XmlPullParser(uint8.buffer);
2798        let result = '';
2799        function func(key, value) {
2800            if (key === xml.EventType.TEXT || key === xml.EventType.CDSECT) {
2801                result += value.getText() + ' ';
2802            }
2803            return true;
2804        }
2805        let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func}
2806        pullParse.parseXml(options);
2807        let str = 'Hello\nWorld Work\n This is a \n CDATA section';
2808        expect(result.trim()).assertEqual(str);
2809    })
2810
2811    /**
2812     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_11300
2813     * @tc.name: testParseXml013
2814     * @tc.desc: Starts parsing he XML file.
2815     * @tc.size: MediumTest
2816     * @tc.type: Function
2817     * @tc.level: Level 1
2818     */
2819    it('testParseXml013', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2820        let strXml =
2821            '<?xml version="1.0" encoding="utf-8"?>' +
2822            '<note importance="hi&amp;gh" logged="&lt;true">' +
2823            '    <title>Hello&gt;World&apos;</title>' +
2824            '    <todo>Wo&quot;rk</todo>' +
2825            '</note>';
2826        let textEncoder = new util.TextEncoder();
2827        let uint8 = textEncoder.encodeInto(strXml);
2828        let pullParse = new xml.XmlPullParser(uint8.buffer);
2829        let resAttr = '';
2830        let result = '';
2831        function funcAttr(name, value) {
2832            resAttr += name + ', ' + value + ' ';
2833            return true;
2834        }
2835        function func(name, value) {
2836            if (name == xml.EventType.TEXT) {
2837                result += value.getText() + ' ';
2838            }
2839            return true;
2840        }
2841        let options = {supportDoctype:true, ignoreNameSpace:true, attributeValueCallbackFunction: funcAttr,
2842            tokenValueCallbackFunction:func}
2843        pullParse.parseXml(options);
2844        let str = 'Hello>World\' Wo"rk';
2845        let strAttr = 'importance, hi&gh logged, <true';
2846        expect(result.trim()).assertEqual(str);
2847        expect(resAttr.trim()).assertEqual(strAttr);
2848    })
2849
2850    /**
2851     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_11400
2852     * @tc.name: testSetAttributes006
2853     * @tc.desc: Writes the text.
2854     * @tc.size: MediumTest
2855     * @tc.type: Function
2856     * @tc.level: Level 1
2857     */
2858    it('testSetAttributes006', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2859        const myMAX = 1024;
2860        let arrayBuffer = new ArrayBuffer(myMAX);
2861        let serializer = new xml.XmlSerializer(arrayBuffer);
2862        serializer.startElement('note');
2863        serializer.setAttributes('importance', 'Hello>World');
2864        serializer.setText('high');
2865        serializer.endElement();
2866        let uint8 = new Uint8Array(arrayBuffer);
2867        let xmlStr = '<note importance="Hello&gt;World">high</note>';
2868        let result = '';
2869        for (let i = 0; i < xmlStr.length; ++i) {
2870            result = result + String.fromCodePoint(uint8[i]);
2871        }
2872        expect(result).assertEqual(xmlStr);
2873    })
2874
2875    /**
2876     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_11500
2877     * @tc.name: testSetAttributes007
2878     * @tc.desc: Writes the text.
2879     * @tc.size: MediumTest
2880     * @tc.type: Function
2881     * @tc.level: Level 1
2882     */
2883    it('testSetAttributes007', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2884        const myMAX = 1024;
2885        let arrayBuffer = new ArrayBuffer(myMAX);
2886        let serializer = new xml.XmlSerializer(arrayBuffer);
2887        serializer.startElement('note');
2888        serializer.setAttributes('importance', 'Hello<World');
2889        serializer.setText('high');
2890        serializer.endElement();
2891        let uint8 = new Uint8Array(arrayBuffer);
2892        let xmlStr = '<note importance="Hello&lt;World">high</note>';
2893        let result = '';
2894        for (let i = 0; i < xmlStr.length; ++i) {
2895            result = result + String.fromCodePoint(uint8[i]);
2896        }
2897        expect(result).assertEqual(xmlStr);
2898    })
2899
2900    /**
2901     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_11600
2902     * @tc.name: testSetAttributes008
2903     * @tc.desc: Writes the text.
2904     * @tc.size: MediumTest
2905     * @tc.type: Function
2906     * @tc.level: Level 1
2907     */
2908    it('testSetAttributes008', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2909        const myMAX = 1024;
2910        let arrayBuffer = new ArrayBuffer(myMAX);
2911        let serializer = new xml.XmlSerializer(arrayBuffer);
2912        serializer.startElement('note');
2913        serializer.setAttributes('importance', 'Hello&World');
2914        serializer.setText('high');
2915        serializer.endElement();
2916        let uint8 = new Uint8Array(arrayBuffer);
2917        let xmlStr = '<note importance="Hello&amp;World">high</note>';
2918        let result = '';
2919        for (let i = 0; i < xmlStr.length; ++i) {
2920            result = result + String.fromCodePoint(uint8[i]);
2921        }
2922        expect(result).assertEqual(xmlStr);
2923    })
2924
2925    /**
2926     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_11700
2927     * @tc.name: testSetAttributes009
2928     * @tc.desc: Writes the text.
2929     * @tc.size: MediumTest
2930     * @tc.type: Function
2931     * @tc.level: Level 1
2932     */
2933    it('testSetAttributes009', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2934        const myMAX = 1024;
2935        let arrayBuffer = new ArrayBuffer(myMAX);
2936        let serializer = new xml.XmlSerializer(arrayBuffer);
2937        serializer.startElement('note');
2938        serializer.setAttributes('importance', 'Hello\'World');
2939        serializer.setText('high');
2940        serializer.endElement();
2941        let uint8 = new Uint8Array(arrayBuffer);
2942        let xmlStr = '<note importance="Hello&apos;World">high</note>';
2943        let result = '';
2944        for (let i = 0; i < xmlStr.length; ++i) {
2945            result = result + String.fromCodePoint(uint8[i]);
2946        }
2947        expect(result).assertEqual(xmlStr);
2948    })
2949
2950    /**
2951     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_11800
2952     * @tc.name: testSetAttributes010
2953     * @tc.desc: Writes the text.
2954     * @tc.size: MediumTest
2955     * @tc.type: Function
2956     * @tc.level: Level 1
2957     */
2958    it('testSetAttributes010', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2959        const myMAX = 1024;
2960        let arrayBuffer = new ArrayBuffer(myMAX);
2961        let serializer = new xml.XmlSerializer(arrayBuffer);
2962        serializer.startElement('note');
2963        serializer.setAttributes('importance', 'Hello"World');
2964        serializer.setText('high');
2965        serializer.endElement();
2966        let uint8 = new Uint8Array(arrayBuffer);
2967        let xmlStr = '<note importance="Hello&quot;World">high</note>';
2968        let result = '';
2969        for (let i = 0; i < xmlStr.length; ++i) {
2970            result = result + String.fromCodePoint(uint8[i]);
2971        }
2972        expect(result).assertEqual(xmlStr);
2973    })
2974
2975    /**
2976     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_11900
2977     * @tc.name: testSetCDATA006
2978     * @tc.desc: Writes the CDATA.
2979     * @tc.size: MediumTest
2980     * @tc.type: Function
2981     * @tc.level: Level 1
2982     */
2983    it('testSetCDATA006', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
2984        const myMAX = 2048;
2985        let arrayBuffer = new ArrayBuffer(myMAX);
2986        let serializer = new xml.XmlSerializer(arrayBuffer);
2987        serializer.startElement("note");
2988        serializer.setCDATA(']]>')
2989        serializer.endElement();
2990        let xmlStr = '<note>\r\n  <![CDATA[]]]]><![CDATA[>]]>\r\n</note>';
2991        let uint8 = new Uint8Array(arrayBuffer);
2992        let result = "";
2993        for (let i = 0; i < xmlStr.length; ++i) {
2994            result += String.fromCodePoint(uint8[i]);
2995        }
2996        expect(result).assertEqual(xmlStr);
2997    })
2998
2999    /**
3000     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_12000
3001     * @tc.name: testSetCDATA007
3002     * @tc.desc: Writes the CDATA.
3003     * @tc.size: MediumTest
3004     * @tc.type: Function
3005     * @tc.level: Level 1
3006     */
3007    it('testSetCDATA007', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3008        const myMAX = 2048;
3009        let arrayBuffer = new ArrayBuffer(myMAX);
3010        let serializer = new xml.XmlSerializer(arrayBuffer);
3011        serializer.startElement("note");
3012        serializer.setCDATA('<![CDATA[]]>')
3013        serializer.endElement();
3014        let xmlStr = '<note>\r\n  <![CDATA[<![CDATA[]]]]><![CDATA[>]]>\r\n</note>';
3015        let uint8 = new Uint8Array(arrayBuffer);
3016        let result = "";
3017        for (let i = 0; i < xmlStr.length; ++i) {
3018            result += String.fromCodePoint(uint8[i]);
3019        }
3020        expect(result).assertEqual(xmlStr);
3021    })
3022
3023    /**
3024     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_12100
3025     * @tc.name: testSetCDATA008
3026     * @tc.desc: Writes the CDATA.
3027     * @tc.size: MediumTest
3028     * @tc.type: Function
3029     * @tc.level: Level 1
3030     */
3031    it('testSetCDATA008', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3032        const myMAX = 2048;
3033        let arrayBuffer = new ArrayBuffer(myMAX);
3034        let serializer = new xml.XmlSerializer(arrayBuffer);
3035        serializer.startElement("note");
3036        serializer.setCDATA('fun() {if (a < b) return;}')
3037        serializer.endElement();
3038        let xmlStr = '<note>\r\n  <![CDATA[fun() {if (a < b) return;}]]>\r\n</note>';
3039        let uint8 = new Uint8Array(arrayBuffer);
3040        let result = "";
3041        for (let i = 0; i < xmlStr.length; ++i) {
3042            result += String.fromCodePoint(uint8[i]);
3043        }
3044        expect(result).assertEqual(xmlStr);
3045    })
3046
3047    /**
3048     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_12200
3049     * @tc.name: testSetCDATA009
3050     * @tc.desc: Writes the CDATA.
3051     * @tc.size: MediumTest
3052     * @tc.type: Function
3053     * @tc.level: Level 1
3054     */
3055    it('testSetCDATA009', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3056        const myMAX = 2048;
3057        let arrayBuffer = new ArrayBuffer(myMAX);
3058        let serializer = new xml.XmlSerializer(arrayBuffer);
3059        serializer.startElement("note");
3060        serializer.setCDATA('fun() {if (a && b) return;}')
3061        serializer.endElement();
3062        let xmlStr = '<note>\r\n  <![CDATA[fun() {if (a && b) return;}]]>\r\n</note>';
3063        let uint8 = new Uint8Array(arrayBuffer);
3064        let result = "";
3065        for (let i = 0; i < xmlStr.length; ++i) {
3066            result += String.fromCodePoint(uint8[i]);
3067        }
3068        expect(result).assertEqual(xmlStr);
3069    })
3070
3071    /**
3072     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_12300
3073     * @tc.name: testSetCDATA0010
3074     * @tc.desc: Writes the CDATA.
3075     * @tc.size: MediumTest
3076     * @tc.type: Function
3077     * @tc.level: Level 1
3078     */
3079    it('testSetCDATA0010', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3080        const myMAX = 2048;
3081        let arrayBuffer = new ArrayBuffer(myMAX);
3082        let serializer = new xml.XmlSerializer(arrayBuffer);
3083        serializer.startElement("note");
3084        serializer.setCDATA('fun() {if (a == \'xml\') return;}')
3085        serializer.endElement();
3086        let xmlStr = '<note>\r\n  <![CDATA[fun() {if (a == \'xml\') return;}]]>\r\n</note>';
3087        let uint8 = new Uint8Array(arrayBuffer);
3088        let result = "";
3089        for (let i = 0; i < xmlStr.length; ++i) {
3090            result += String.fromCodePoint(uint8[i]);
3091        }
3092        expect(result).assertEqual(xmlStr);
3093    })
3094
3095    /**
3096     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_12400
3097     * @tc.name: testParseXml014
3098     * @tc.desc: Starts parsing the XML file.
3099     * @tc.size: MediumTest
3100     * @tc.type: Function
3101     * @tc.level: Level 1
3102     */
3103    it('testParseXml014', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3104        let strXml =
3105            '<?xml version="1.0" encoding="UTF-8"?>' +
3106            '<note importance="high" logged="true">' +
3107            '<company><![CDATA[SYSTEM</company>' +
3108            '<todo>work</todo>' +
3109            '</note>';
3110        let textEncoder = new util.TextEncoder();
3111        let uint8 = textEncoder.encodeInto(strXml);
3112        let pullParse = new xml.XmlPullParser(uint8.buffer);
3113        let result = '';
3114        function func(name, value) {
3115            result += name + value;
3116            return true;
3117        }
3118        let options = {supportDoctype:true, ignoreNameSpace:true, tagValueCallbackFunction:func}
3119        try {
3120            pullParse.parseXml(options);
3121            expect().assertFail();
3122        } catch (e) {
3123            expect(e.toString()).assertEqual("BusinessError: Cannot find the ']]>' in xml string.");
3124            expect(e.code).assertEqual(401);
3125        }
3126    })
3127
3128    /**
3129     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_12500
3130     * @tc.name: testParseXml015
3131     * @tc.desc: Starts parsing the XML file.
3132     * @tc.size: MediumTest
3133     * @tc.type: Function
3134     * @tc.level: Level 1
3135     */
3136    it('testParseXml015', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3137        let strXml =
3138            '<?xml version="1.0" encoding="UTF-8"?>' +
3139            '<note importance="high" logged="true">' +
3140            '<company><![CDATA[';
3141        let textEncoder = new util.TextEncoder();
3142        let uint8 = textEncoder.encodeInto(strXml);
3143        let pullParse = new xml.XmlPullParser(uint8.buffer);
3144        let result = '';
3145        function func(name, value) {
3146            result += name + value;
3147            return true;
3148        }
3149        let options = {supportDoctype:true, ignoreNameSpace:true, tagValueCallbackFunction:func}
3150        try {
3151            pullParse.parseXml(options);
3152            expect().assertFail();
3153        } catch (e) {
3154            expect(e.toString()).assertEqual("BusinessError: Cannot find the ']]>' in xml string.");
3155            expect(e.code).assertEqual(401);
3156        }
3157    })
3158
3159    /**
3160     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_12600
3161     * @tc.name: testParseXml016
3162     * @tc.desc: Starts parsing the XML file.
3163     * @tc.size: MediumTest
3164     * @tc.type: Function
3165     * @tc.level: Level 1
3166     */
3167    it('testParseXml016', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3168        let strXml =
3169            '<?xml version="1.0" encoding="utf-8"?>' +
3170            '<note importance="high" logged="true">' +
3171            '<title>Happy</title>' +
3172            '<?go there' +
3173            '</note>';
3174        let textEncoder = new util.TextEncoder();
3175        let uint8 = textEncoder.encodeInto(strXml);
3176        let pullParse = new xml.XmlPullParser(uint8.buffer);
3177        let result = '';
3178        function func(name, value) {
3179            result += name + value;
3180            return true;
3181        }
3182        let options = {supportDoctype:true, ignoreNameSpace:true, tagValueCallbackFunction:func}
3183        try {
3184            pullParse.parseXml(options);
3185            expect().assertFail();
3186        } catch (e) {
3187            expect(e.toString()).assertEqual("BusinessError: Cannot find the '?>' in xml string.");
3188            expect(e.code).assertEqual(401);
3189        }
3190    })
3191
3192    /**
3193     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_12700
3194     * @tc.name: testParseXml017
3195     * @tc.desc: Starts parsing the XML file.
3196     * @tc.size: MediumTest
3197     * @tc.type: Function
3198     * @tc.level: Level 1
3199     */
3200    it('testParseXml017', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3201        let strXml =
3202            '<?xml version="1.0" encoding="utf-8"?>' +
3203            '<note importance="high" logged="true">' +
3204            '<title>Happy</title>' +
3205            '<?go there';
3206        let textEncoder = new util.TextEncoder();
3207        let uint8 = textEncoder.encodeInto(strXml);
3208        let pullParse = new xml.XmlPullParser(uint8.buffer);
3209        let result = '';
3210        function func(name, value) {
3211            result += name + value;
3212            return true;
3213        }
3214        let options = {supportDoctype:true, ignoreNameSpace:true, tagValueCallbackFunction:func}
3215        try {
3216            pullParse.parseXml(options);
3217            expect().assertFail();
3218        } catch (e) {
3219            expect(e.toString()).assertEqual("BusinessError: Cannot find the '?>' in xml string.");
3220            expect(e.code).assertEqual(401);
3221        }
3222    })
3223
3224    /**
3225     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_12800
3226     * @tc.name: testParseXml018
3227     * @tc.desc: Starts parsing the XML file.
3228     * @tc.size: MediumTest
3229     * @tc.type: Function
3230     * @tc.level: Level 1
3231     */
3232    it('testParseXml018', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3233        let strXml =
3234            '<?xml version="1.0" encoding="utf-8"?>' +
3235            '<note importance="high" logged="true">' +
3236            '<title>Happy</title>' +
3237            '<!--comment' +
3238            '</note>';
3239        let textEncoder = new util.TextEncoder();
3240        let uint8 = textEncoder.encodeInto(strXml);
3241        let pullParse = new xml.XmlPullParser(uint8.buffer);
3242        let result = '';
3243        function func(name, value) {
3244            result += name + value;
3245            return true;
3246        }
3247        let options = {supportDoctype:true, ignoreNameSpace:true, tagValueCallbackFunction:func}
3248        try {
3249            pullParse.parseXml(options);
3250            expect().assertFail();
3251        } catch (e) {
3252            expect(e.toString()).assertEqual("BusinessError: Cannot find the '--' in xml string.");
3253            expect(e.code).assertEqual(401);
3254        }
3255    })
3256
3257    /**
3258     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_12900
3259     * @tc.name: testParseXml019
3260     * @tc.desc: Starts parsing the XML file.
3261     * @tc.size: MediumTest
3262     * @tc.type: Function
3263     * @tc.level: Level 1
3264     */
3265    it('testParseXml019', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3266        let strXml =
3267            '<?xml version="1.0" encoding="utf-8"?>' +
3268            '<column name="Giana"><value integer="1"/></column>' +
3269            '<column name="category"><value Boolean="true"/></column>' +
3270            '<column name="day"><value Boolean="3"/></column>';
3271        let textEncoder = new util.TextEncoder();
3272        let uint8 = textEncoder.encodeInto(strXml);
3273        let pullParse = new xml.XmlPullParser(uint8.buffer, 'UTF-8');
3274        let findCategory = false;
3275        let categoryValue = "";
3276        function attrWithTag(tagName, key, value) {
3277            if (value === '1') {
3278                findCategory = true;
3279                return true;
3280            }
3281            if (findCategory) {
3282                categoryValue = value;
3283                return false;
3284            }
3285            return true;
3286        }
3287        let options = {supportDoctype:true, ignoreNameSpace:true, attributeWithTagCallbackFunction:attrWithTag}
3288        pullParse.parseXml(options);
3289        let result = 'category';
3290        expect(categoryValue).assertEqual(result);
3291    })
3292
3293    /**
3294     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_13000
3295     * @tc.name: testParseXml020
3296     * @tc.desc: Starts parsing the XML file.
3297     * @tc.size: MediumTest
3298     * @tc.type: Function
3299     * @tc.level: Level 1
3300     */
3301    it('testParseXml020', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3302        let strXml =
3303            '<?xml version="1.0" encoding="utf-8"?>' +
3304            '<column name="Giana"><value integer="1"/></column>' +
3305            '<column name="category"><value Boolean="true"/></column>' +
3306            '<column name="day"><value Boolean="3"/></column>';
3307        let textEncoder = new util.TextEncoder();
3308        let uint8 = textEncoder.encodeInto(strXml);
3309        let pullParse = new xml.XmlPullParser(uint8.buffer, 'UTF-8');
3310        let str = '';
3311        function attrWithTag(tagName, key, value) {
3312            if (value === 'category') {
3313                return false;
3314            }
3315            str += tagName + ' ' + key + ' ' + value + ' ';
3316            return true;
3317        }
3318        let options = {supportDoctype:true, ignoreNameSpace:true, attributeWithTagCallbackFunction:attrWithTag}
3319        pullParse.parseXml(options);
3320        let result = 'column name Giana value integer 1';
3321        expect(str.trim()).assertEqual(result);
3322    })
3323
3324    /**
3325     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_13100
3326     * @tc.name: testParseXml021
3327     * @tc.desc: Starts parsing the XML file.
3328     * @tc.size: MediumTest
3329     * @tc.type: Function
3330     * @tc.level: Level 1
3331     */
3332    it('testParseXml021', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3333        let strXml =
3334            '<?xml version="1.0" encoding="utf-8"?>' +
3335            '<column name="Giana"><value integer="1"/></column>' +
3336            '<column name="category"><value Boolean="true"/></column>' +
3337            '<column name="day"><value Boolean="3"/></column>';
3338        let textEncoder = new util.TextEncoder();
3339        let uint8 = textEncoder.encodeInto(strXml);
3340        let pullParse = new xml.XmlPullParser(uint8.buffer, 'UTF-8');
3341        let str = '';
3342        function attrWithTag(tagName, key, value) {
3343            if (value === 'category') {
3344                return false;
3345            }
3346            str += key + ' ' + value + ' ';
3347            return true;
3348        }
3349        let options = {supportDoctype:true, ignoreNameSpace:true, attributeWithTagCallbackFunction:attrWithTag}
3350        pullParse.parseXml(options);
3351        let result = 'name Giana integer 1';
3352        expect(str.trim()).assertEqual(result);
3353    })
3354
3355    /**
3356     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_13200
3357     * @tc.name: testParseXml022
3358     * @tc.desc: Starts parsing the XML file.
3359     * @tc.size: MediumTest
3360     * @tc.type: Function
3361     * @tc.level: Level 1
3362     */
3363    it('testParseXml022', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3364        let strXml =
3365            '<?xml version="1.0" encoding="utf-8"?>' +
3366            '<column name="Giana"><value integer="1"/></column>' +
3367            '<column name="category"><value Boolean="true"/></column>';
3368        let textEncoder = new util.TextEncoder();
3369        let uint8 = textEncoder.encodeInto(strXml);
3370        let pullParse = new xml.XmlPullParser(uint8.buffer, 'UTF-8');
3371        let str = '';
3372        function attrWithTag(tagName, key, value) {
3373            str += tagName + ' ' + key + ' ' + value + ' ';
3374            return true;
3375        }
3376        let options = {supportDoctype:true, ignoreNameSpace:true, attributeWithTagCallbackFunction:attrWithTag}
3377        pullParse.parseXml(options);
3378        let result = 'column name Giana value integer 1 column name category value Boolean true';
3379        expect(str.trim()).assertEqual(result);
3380    })
3381
3382    /**
3383     * @tc.number: SUB_COMMONLIBRARY_ETSUTILS_XML_13300
3384     * @tc.name: testParseXml023
3385     * @tc.desc: Starts parsing the XML file.
3386     * @tc.size: MediumTest
3387     * @tc.type: Function
3388     * @tc.level: Level 1
3389     */
3390    it('testParseXml023', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1, function () {
3391        let strXml =
3392            '<?xml version="1.0" encoding="utf-8"?>' +
3393            '<column name="Giana"><value integer="1"/></column>' +
3394            '<column name="category"><value Boolean="true"/></column>';
3395        let textEncoder = new util.TextEncoder();
3396        let uint8 = textEncoder.encodeInto(strXml);
3397        let pullParse = new xml.XmlPullParser(uint8.buffer, 'UTF-8');
3398        let str = '';
3399        function attrWithTag(tagName, key, value) {
3400            str += key + ' ' + value + ' ';
3401            return true;
3402        }
3403        let options = {supportDoctype:true, ignoreNameSpace:true, attributeWithTagCallbackFunction:attrWithTag}
3404        pullParse.parseXml(options);
3405        let result = 'name Giana integer 1 name category Boolean true';
3406        expect(str.trim()).assertEqual(result);
3407    })
3408})}