• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-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 */
15
16/**
17 * @file
18 * @kit ArkTS
19 */
20
21/**
22 * The convertxml module provides utilities for converting XML text to Javascript object.
23 *
24 * @namespace xml
25 * @syscap SystemCapability.Utils.Lang
26 * @since 8
27 */
28/**
29 * The convertxml module provides utilities for converting XML text to Javascript object.
30 *
31 * @namespace xml
32 * @syscap SystemCapability.Utils.Lang
33 * @crossplatform
34 * @since 10
35 */
36/**
37 * The convertxml module provides utilities for converting XML text to Javascript object.
38 *
39 * @namespace xml
40 * @syscap SystemCapability.Utils.Lang
41 * @crossplatform
42 * @atomicservice
43 * @since 11
44 */
45declare namespace xml {
46  /**
47   * The options for conversion.
48   *
49   * @interface ConvertOptions
50   * @syscap SystemCapability.Utils.Lang
51   * @since 8
52   */
53  /**
54   * The options for conversion.
55   *
56   * @interface ConvertOptions
57   * @syscap SystemCapability.Utils.Lang
58   * @crossplatform
59   * @since 10
60   */
61  /**
62   * The options for conversion.
63   *
64   * @interface ConvertOptions
65   * @syscap SystemCapability.Utils.Lang
66   * @crossplatform
67   * @atomicservice
68   * @since 11
69   */
70  interface ConvertOptions {
71    /**
72     * Whether to trim whitespace characters that may exist before and after the text, default false.
73     *
74     * @type { boolean }
75     * @syscap SystemCapability.Utils.Lang
76     * @since 8
77     */
78    /**
79     * Whether to trim whitespace characters that may exist before and after the text, default false.
80     *
81     * @type { boolean }
82     * @syscap SystemCapability.Utils.Lang
83     * @crossplatform
84     * @since 10
85     */
86    /**
87     * Whether to trim whitespace characters that may exist before and after the text, default false.
88     *
89     * @type { boolean }
90     * @syscap SystemCapability.Utils.Lang
91     * @crossplatform
92     * @atomicservice
93     * @since 11
94     */
95    trim: boolean;
96    /**
97     * Whether to ignore writing declaration directives of xml.
98     *
99     * @type { ?boolean }
100     * @syscap SystemCapability.Utils.Lang
101     * @since 8
102     */
103    /**
104     * Whether to ignore writing declaration directives of xml.
105     *
106     * @type { ?boolean }
107     * @syscap SystemCapability.Utils.Lang
108     * @crossplatform
109     * @since 10
110     */
111    /**
112     * Whether to ignore writing declaration directives of xml.
113     *
114     * @type { ?boolean }
115     * @syscap SystemCapability.Utils.Lang
116     * @crossplatform
117     * @atomicservice
118     * @since 11
119     */
120    ignoreDeclaration?: boolean;
121    /**
122     * Whether to ignore writing processing instruction of xml.
123     *
124     * @type { ?boolean }
125     * @syscap SystemCapability.Utils.Lang
126     * @since 8
127     */
128    /**
129     * Whether to ignore writing processing instruction of xml.
130     *
131     * @type { ?boolean }
132     * @syscap SystemCapability.Utils.Lang
133     * @crossplatform
134     * @since 10
135     */
136    /**
137     * Whether to ignore writing processing instruction of xml.
138     *
139     * @type { ?boolean }
140     * @syscap SystemCapability.Utils.Lang
141     * @crossplatform
142     * @atomicservice
143     * @since 11
144     */
145    ignoreInstruction?: boolean;
146    /**
147     * Whether to print attributes across multiple lines and indent them.
148     *
149     * @type { ?boolean }
150     * @syscap SystemCapability.Utils.Lang
151     * @since 8
152     */
153    /**
154     * Whether to print attributes across multiple lines and indent them.
155     *
156     * @type { ?boolean }
157     * @syscap SystemCapability.Utils.Lang
158     * @crossplatform
159     * @since 10
160     */
161    /**
162     * Whether to print attributes across multiple lines and indent them.
163     *
164     * @type { ?boolean }
165     * @syscap SystemCapability.Utils.Lang
166     * @crossplatform
167     * @atomicservice
168     * @since 11
169     */
170    ignoreAttributes?: boolean;
171    /**
172     * Whether to ignore writing comments of the elements.
173     *
174     * @type { ?boolean }
175     * @syscap SystemCapability.Utils.Lang
176     * @since 8
177     */
178    /**
179     * Whether to ignore writing comments of the elements.
180     *
181     * @type { ?boolean }
182     * @syscap SystemCapability.Utils.Lang
183     * @crossplatform
184     * @since 10
185     */
186    /**
187     * Whether to ignore writing comments of the elements.
188     *
189     * @type { ?boolean }
190     * @syscap SystemCapability.Utils.Lang
191     * @crossplatform
192     * @atomicservice
193     * @since 11
194     */
195    ignoreComment?: boolean;
196    /**
197     * Whether to ignore writing CDATA of the elements.
198     *
199     * @type { ?boolean }
200     * @syscap SystemCapability.Utils.Lang
201     * @since 8
202     */
203    /**
204     * Whether to ignore writing CDATA of the elements.
205     *
206     * @type { ?boolean }
207     * @syscap SystemCapability.Utils.Lang
208     * @crossplatform
209     * @since 10
210     */
211    /**
212     * Whether to ignore writing CDATA of the elements.
213     *
214     * @type { ?boolean }
215     * @syscap SystemCapability.Utils.Lang
216     * @crossplatform
217     * @atomicservice
218     * @since 11
219     */
220    ignoreCDATA?: boolean;
221    /**
222     * Whether to ignore writing Doctype of the elements.
223     *
224     * @type { ?boolean }
225     * @syscap SystemCapability.Utils.Lang
226     * @since 8
227     */
228    /**
229     * Whether to ignore writing Doctype of the elements.
230     *
231     * @type { ?boolean }
232     * @syscap SystemCapability.Utils.Lang
233     * @crossplatform
234     * @since 10
235     */
236    /**
237     * Whether to ignore writing Doctype of the elements.
238     *
239     * @type { ?boolean }
240     * @syscap SystemCapability.Utils.Lang
241     * @crossplatform
242     * @atomicservice
243     * @since 11
244     */
245    ignoreDoctype?: boolean;
246    /**
247     * Whether to ignore writing texts of the elements.
248     *
249     * @type { ?boolean }
250     * @syscap SystemCapability.Utils.Lang
251     * @since 8
252     */
253    /**
254     * Whether to ignore writing texts of the elements.
255     *
256     * @type { ?boolean }
257     * @syscap SystemCapability.Utils.Lang
258     * @crossplatform
259     * @since 10
260     */
261    /**
262     * Whether to ignore writing texts of the elements.
263     *
264     * @type { ?boolean }
265     * @syscap SystemCapability.Utils.Lang
266     * @crossplatform
267     * @atomicservice
268     * @since 11
269     */
270    ignoreText?: boolean;
271    /**
272     * Name of the property key which will be used for the declaration.
273     *
274     * @type { string }
275     * @syscap SystemCapability.Utils.Lang
276     * @since 8
277     */
278    /**
279     * Name of the property key which will be used for the declaration.
280     *
281     * @type { string }
282     * @syscap SystemCapability.Utils.Lang
283     * @crossplatform
284     * @since 10
285     */
286    /**
287     * Name of the property key which will be used for the declaration.
288     *
289     * @type { string }
290     * @syscap SystemCapability.Utils.Lang
291     * @crossplatform
292     * @atomicservice
293     * @since 11
294     */
295    declarationKey: string;
296    /**
297     * Name of the property key which will be used for the processing instruction.
298     *
299     * @type { string }
300     * @syscap SystemCapability.Utils.Lang
301     * @since 8
302     */
303    /**
304     * Name of the property key which will be used for the processing instruction.
305     *
306     * @type { string }
307     * @syscap SystemCapability.Utils.Lang
308     * @crossplatform
309     * @since 10
310     */
311    /**
312     * Name of the property key which will be used for the processing instruction.
313     *
314     * @type { string }
315     * @syscap SystemCapability.Utils.Lang
316     * @crossplatform
317     * @atomicservice
318     * @since 11
319     */
320    instructionKey: string;
321    /**
322     * Name of the property key which will be used for the attributes.
323     *
324     * @type { string }
325     * @syscap SystemCapability.Utils.Lang
326     * @since 8
327     */
328    /**
329     * Name of the property key which will be used for the attributes.
330     *
331     * @type { string }
332     * @syscap SystemCapability.Utils.Lang
333     * @crossplatform
334     * @since 10
335     */
336    /**
337     * Name of the property key which will be used for the attributes.
338     *
339     * @type { string }
340     * @syscap SystemCapability.Utils.Lang
341     * @crossplatform
342     * @atomicservice
343     * @since 11
344     */
345    attributesKey: string;
346    /**
347     * Name of the property key which will be used for the text.
348     *
349     * @type { string }
350     * @syscap SystemCapability.Utils.Lang
351     * @since 8
352     */
353    /**
354     * Name of the property key which will be used for the text.
355     *
356     * @type { string }
357     * @syscap SystemCapability.Utils.Lang
358     * @crossplatform
359     * @since 10
360     */
361    /**
362     * Name of the property key which will be used for the text.
363     *
364     * @type { string }
365     * @syscap SystemCapability.Utils.Lang
366     * @crossplatform
367     * @atomicservice
368     * @since 11
369     */
370    textKey: string;
371    /**
372     * Name of the property key which will be used for the cdata.
373     *
374     * @type { string }
375     * @syscap SystemCapability.Utils.Lang
376     * @since 8
377     */
378    /**
379     * Name of the property key which will be used for the cdata.
380     *
381     * @type { string }
382     * @syscap SystemCapability.Utils.Lang
383     * @crossplatform
384     * @since 10
385     */
386    /**
387     * Name of the property key which will be used for the cdata.
388     *
389     * @type { string }
390     * @syscap SystemCapability.Utils.Lang
391     * @crossplatform
392     * @atomicservice
393     * @since 11
394     */
395    cdataKey: string;
396    /**
397     * Name of the property key which will be used for the doctype.
398     *
399     * @type { string }
400     * @syscap SystemCapability.Utils.Lang
401     * @since 8
402     */
403    /**
404     * Name of the property key which will be used for the doctype.
405     *
406     * @type { string }
407     * @syscap SystemCapability.Utils.Lang
408     * @crossplatform
409     * @since 10
410     */
411    /**
412     * Name of the property key which will be used for the doctype.
413     *
414     * @type { string }
415     * @syscap SystemCapability.Utils.Lang
416     * @crossplatform
417     * @atomicservice
418     * @since 11
419     */
420    doctypeKey: string;
421    /**
422     * Name of the property key which will be used for the comment.
423     *
424     * @type { string }
425     * @syscap SystemCapability.Utils.Lang
426     * @since 8
427     */
428    /**
429     * Name of the property key which will be used for the comment.
430     *
431     * @type { string }
432     * @syscap SystemCapability.Utils.Lang
433     * @crossplatform
434     * @since 10
435     */
436    /**
437     * Name of the property key which will be used for the comment.
438     *
439     * @type { string }
440     * @syscap SystemCapability.Utils.Lang
441     * @crossplatform
442     * @atomicservice
443     * @since 11
444     */
445    commentKey: string;
446    /**
447     * Name of the property key which will be used for the parent.
448     *
449     * @type { string }
450     * @syscap SystemCapability.Utils.Lang
451     * @since 8
452     */
453    /**
454     * Name of the property key which will be used for the parent.
455     *
456     * @type { string }
457     * @syscap SystemCapability.Utils.Lang
458     * @crossplatform
459     * @since 10
460     */
461    /**
462     * Name of the property key which will be used for the parent.
463     *
464     * @type { string }
465     * @syscap SystemCapability.Utils.Lang
466     * @crossplatform
467     * @atomicservice
468     * @since 11
469     */
470    parentKey: string;
471    /**
472     * Name of the property key which will be used for the type.
473     *
474     * @type { string }
475     * @syscap SystemCapability.Utils.Lang
476     * @since 8
477     */
478    /**
479     * Name of the property key which will be used for the type.
480     *
481     * @type { string }
482     * @syscap SystemCapability.Utils.Lang
483     * @crossplatform
484     * @since 10
485     */
486    /**
487     * Name of the property key which will be used for the type.
488     *
489     * @type { string }
490     * @syscap SystemCapability.Utils.Lang
491     * @crossplatform
492     * @atomicservice
493     * @since 11
494     */
495    typeKey: string;
496    /**
497     * Name of the property key which will be used for the name.
498     *
499     * @type { string }
500     * @syscap SystemCapability.Utils.Lang
501     * @since 8
502     */
503    /**
504     * Name of the property key which will be used for the name.
505     *
506     * @type { string }
507     * @syscap SystemCapability.Utils.Lang
508     * @crossplatform
509     * @since 10
510     */
511    /**
512     * Name of the property key which will be used for the name.
513     *
514     * @type { string }
515     * @syscap SystemCapability.Utils.Lang
516     * @crossplatform
517     * @atomicservice
518     * @since 11
519     */
520    nameKey: string;
521    /**
522     * Name of the property key which will be used for the elements.
523     *
524     * @type { string }
525     * @syscap SystemCapability.Utils.Lang
526     * @since 8
527     */
528    /**
529     * Name of the property key which will be used for the elements.
530     *
531     * @type { string }
532     * @syscap SystemCapability.Utils.Lang
533     * @crossplatform
534     * @since 10
535     */
536    /**
537     * Name of the property key which will be used for the elements.
538     *
539     * @type { string }
540     * @syscap SystemCapability.Utils.Lang
541     * @crossplatform
542     * @atomicservice
543     * @since 11
544     */
545    elementsKey: string;
546  }
547
548  /**
549   * ConvertXML representation refers to extensible markup language.
550   *
551   * @syscap SystemCapability.Utils.Lang
552   * @since 8
553   * @name ConvertXML
554   */
555  /**
556   * ConvertXML representation refers to extensible markup language.
557   *
558   * @syscap SystemCapability.Utils.Lang
559   * @crossplatform
560   * @since 10
561   * @name ConvertXML
562   */
563  /**
564   * ConvertXML representation refers to extensible markup language.
565   *
566   * @syscap SystemCapability.Utils.Lang
567   * @crossplatform
568   * @atomicservice
569   * @since 11
570   */
571  class ConvertXML {
572    /**
573     * To convert XML text to JavaScript object.
574     *
575     * @param { string } xml - xml xml The xml text to be converted.
576     * @param { ConvertOptions } options - options option Option Inputted by user to set.
577     * @returns { Object } Returns a JavaScript object converting from XML text.
578     * @syscap SystemCapability.Utils.Lang
579     * @since 8
580     * @deprecated since 9
581     * @useinstead ohos.convertxml.ConvertXML.convertToJSObject
582     */
583    convert(xml: string, options?: ConvertOptions): Object;
584
585    /**
586     * To convert XML text to JavaScript object.
587     *
588     * @param { string } xml - xml xml The xml text to be converted.
589     * @param { ConvertOptions } [options] - options option Option Inputted by user to set.
590     * @returns { Object } Returns a JavaScript object converting from XML text.
591     * @throws { BusinessError } 401 - Parameter error. Possible causes:
592     * 1.Mandatory parameters are left unspecified;
593     * 2.Incorrect parameter types.
594     * @throws { BusinessError } 10200002 - Invalid xml string.
595     * @syscap SystemCapability.Utils.Lang
596     * @since 9
597     */
598    /**
599     * To convert XML text to JavaScript object.
600     *
601     * @param { string } xml - xml xml The xml text to be converted.
602     * @param { ConvertOptions } [options] - options option Option Inputted by user to set.
603     * @returns { Object } Returns a JavaScript object converting from XML text.
604     * @throws { BusinessError } 401 - Parameter error. Possible causes:
605     * 1.Mandatory parameters are left unspecified;
606     * 2.Incorrect parameter types.
607     * @throws { BusinessError } 10200002 - Invalid xml string.
608     * @syscap SystemCapability.Utils.Lang
609     * @crossplatform
610     * @since 10
611     */
612    /**
613     * To convert XML text to JavaScript object.
614     *
615     * @param { string } xml - xml xml The xml text to be converted.
616     * @param { ConvertOptions } [options] - options option Option Inputted by user to set.
617     * @returns { Object } Returns a JavaScript object converting from XML text.
618     * @throws { BusinessError } 401 - Parameter error. Possible causes:
619     * 1.Mandatory parameters are left unspecified;
620     * 2.Incorrect parameter types.
621     * @throws { BusinessError } 10200002 - Invalid xml string.
622     * @syscap SystemCapability.Utils.Lang
623     * @crossplatform
624     * @atomicservice
625     * @since 11
626     */
627    /**
628     * To convert XML text to JavaScript object.
629     *
630     * @param { string } xml - xml xml The xml text to be converted.
631     * @param { ConvertOptions } [options] - options option Option Inputted by user to set.
632     * @returns { Object } Returns a JavaScript object converting from XML text.
633     * @throws { BusinessError } 401 - Parameter error. Possible causes:
634     * 1.Mandatory parameters are left unspecified;
635     * 2.Incorrect parameter types.
636     * @throws { BusinessError } 10200002 - Invalid xml string.
637     * @syscap SystemCapability.Utils.Lang
638     * @crossplatform
639     * @atomicservice
640     * @since 11
641     * @deprecated since 14
642     * @useinstead ohos.convertxml.ConvertXML.fastConvertToJSObject
643     */
644    convertToJSObject(xml: string, options?: ConvertOptions): Object;
645
646    /**
647     * Converts an XML text into a JavaScript object.
648     *
649     * @param { string } xml - XML text to convert. If the XML text contains the ampersand (&), replace it with the
650     * entity reference &.
651     * @param { ConvertOptions } [options] - Options for conversion. The default value is a ConvertOptions object,
652     * which consists of the default values of the attributes in the object.
653     * @returns { Object } Returns a JavaScript object converting from XML text.
654     * @throws { BusinessError } 401 - Parameter error. Possible causes:
655     * 1.Mandatory parameters are left unspecified;
656     * 2.Incorrect parameter types.
657     * @throws { BusinessError } 10200002 - Invalid xml string.
658     * @syscap SystemCapability.Utils.Lang
659     * @crossplatform
660     * @atomicservice
661     * @since 14
662     */
663    fastConvertToJSObject(xml: string, options?: ConvertOptions): Object;
664  }
665}
666export default xml;
667