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 * @syscap SystemCapability.Utils.Lang 75 * @since 8 76 */ 77 /** 78 * Whether to trim whitespace characters that may exist before and after the text, default false. 79 * 80 * @syscap SystemCapability.Utils.Lang 81 * @crossplatform 82 * @since 10 83 */ 84 /** 85 * Whether to trim whitespace characters that may exist before and after the text, default false. 86 * 87 * @syscap SystemCapability.Utils.Lang 88 * @crossplatform 89 * @atomicservice 90 * @since 11 91 */ 92 trim: boolean; 93 /** 94 * Whether to ignore writing declaration directives of xml. 95 * 96 * @syscap SystemCapability.Utils.Lang 97 * @since 8 98 */ 99 /** 100 * Whether to ignore writing declaration directives of xml. 101 * 102 * @syscap SystemCapability.Utils.Lang 103 * @crossplatform 104 * @since 10 105 */ 106 /** 107 * Whether to ignore writing declaration directives of xml. 108 * 109 * @syscap SystemCapability.Utils.Lang 110 * @crossplatform 111 * @atomicservice 112 * @since 11 113 */ 114 ignoreDeclaration?: boolean; 115 /** 116 * Whether to ignore writing processing instruction of xml. 117 * 118 * @syscap SystemCapability.Utils.Lang 119 * @since 8 120 */ 121 /** 122 * Whether to ignore writing processing instruction of xml. 123 * 124 * @syscap SystemCapability.Utils.Lang 125 * @crossplatform 126 * @since 10 127 */ 128 /** 129 * Whether to ignore writing processing instruction of xml. 130 * 131 * @syscap SystemCapability.Utils.Lang 132 * @crossplatform 133 * @atomicservice 134 * @since 11 135 */ 136 ignoreInstruction?: boolean; 137 /** 138 * Whether to print attributes across multiple lines and indent them. 139 * 140 * @syscap SystemCapability.Utils.Lang 141 * @since 8 142 */ 143 /** 144 * Whether to print attributes across multiple lines and indent them. 145 * 146 * @syscap SystemCapability.Utils.Lang 147 * @crossplatform 148 * @since 10 149 */ 150 /** 151 * Whether to print attributes across multiple lines and indent them. 152 * 153 * @syscap SystemCapability.Utils.Lang 154 * @crossplatform 155 * @atomicservice 156 * @since 11 157 */ 158 ignoreAttributes?: boolean; 159 /** 160 * Whether to ignore writing comments of the elements. 161 * 162 * @syscap SystemCapability.Utils.Lang 163 * @since 8 164 */ 165 /** 166 * Whether to ignore writing comments of the elements. 167 * 168 * @syscap SystemCapability.Utils.Lang 169 * @crossplatform 170 * @since 10 171 */ 172 /** 173 * Whether to ignore writing comments of the elements. 174 * 175 * @syscap SystemCapability.Utils.Lang 176 * @crossplatform 177 * @atomicservice 178 * @since 11 179 */ 180 ignoreComment?: boolean; 181 /** 182 * Whether to ignore writing CDATA of the elements. 183 * 184 * @syscap SystemCapability.Utils.Lang 185 * @since 8 186 */ 187 /** 188 * Whether to ignore writing CDATA of the elements. 189 * 190 * @syscap SystemCapability.Utils.Lang 191 * @crossplatform 192 * @since 10 193 */ 194 /** 195 * Whether to ignore writing CDATA of the elements. 196 * 197 * @syscap SystemCapability.Utils.Lang 198 * @crossplatform 199 * @atomicservice 200 * @since 11 201 */ 202 ignoreCDATA?: boolean; 203 /** 204 * Whether to ignore writing Doctype of the elements. 205 * 206 * @syscap SystemCapability.Utils.Lang 207 * @since 8 208 */ 209 /** 210 * Whether to ignore writing Doctype of the elements. 211 * 212 * @syscap SystemCapability.Utils.Lang 213 * @crossplatform 214 * @since 10 215 */ 216 /** 217 * Whether to ignore writing Doctype of the elements. 218 * 219 * @syscap SystemCapability.Utils.Lang 220 * @crossplatform 221 * @atomicservice 222 * @since 11 223 */ 224 ignoreDoctype?: boolean; 225 /** 226 * Whether to ignore writing texts of the elements. 227 * 228 * @syscap SystemCapability.Utils.Lang 229 * @since 8 230 */ 231 /** 232 * Whether to ignore writing texts of the elements. 233 * 234 * @syscap SystemCapability.Utils.Lang 235 * @crossplatform 236 * @since 10 237 */ 238 /** 239 * Whether to ignore writing texts of the elements. 240 * 241 * @syscap SystemCapability.Utils.Lang 242 * @crossplatform 243 * @atomicservice 244 * @since 11 245 */ 246 ignoreText?: boolean; 247 /** 248 * Name of the property key which will be used for the declaration. 249 * 250 * @syscap SystemCapability.Utils.Lang 251 * @since 8 252 */ 253 /** 254 * Name of the property key which will be used for the declaration. 255 * 256 * @syscap SystemCapability.Utils.Lang 257 * @crossplatform 258 * @since 10 259 */ 260 /** 261 * Name of the property key which will be used for the declaration. 262 * 263 * @syscap SystemCapability.Utils.Lang 264 * @crossplatform 265 * @atomicservice 266 * @since 11 267 */ 268 declarationKey: string; 269 /** 270 * Name of the property key which will be used for the processing instruction. 271 * 272 * @syscap SystemCapability.Utils.Lang 273 * @since 8 274 */ 275 /** 276 * Name of the property key which will be used for the processing instruction. 277 * 278 * @syscap SystemCapability.Utils.Lang 279 * @crossplatform 280 * @since 10 281 */ 282 /** 283 * Name of the property key which will be used for the processing instruction. 284 * 285 * @syscap SystemCapability.Utils.Lang 286 * @crossplatform 287 * @atomicservice 288 * @since 11 289 */ 290 instructionKey: string; 291 /** 292 * Name of the property key which will be used for the attributes. 293 * 294 * @syscap SystemCapability.Utils.Lang 295 * @since 8 296 */ 297 /** 298 * Name of the property key which will be used for the attributes. 299 * 300 * @syscap SystemCapability.Utils.Lang 301 * @crossplatform 302 * @since 10 303 */ 304 /** 305 * Name of the property key which will be used for the attributes. 306 * 307 * @syscap SystemCapability.Utils.Lang 308 * @crossplatform 309 * @atomicservice 310 * @since 11 311 */ 312 attributesKey: string; 313 /** 314 * Name of the property key which will be used for the text. 315 * 316 * @syscap SystemCapability.Utils.Lang 317 * @since 8 318 */ 319 /** 320 * Name of the property key which will be used for the text. 321 * 322 * @syscap SystemCapability.Utils.Lang 323 * @crossplatform 324 * @since 10 325 */ 326 /** 327 * Name of the property key which will be used for the text. 328 * 329 * @syscap SystemCapability.Utils.Lang 330 * @crossplatform 331 * @atomicservice 332 * @since 11 333 */ 334 textKey: string; 335 /** 336 * Name of the property key which will be used for the cdata. 337 * 338 * @syscap SystemCapability.Utils.Lang 339 * @since 8 340 */ 341 /** 342 * Name of the property key which will be used for the cdata. 343 * 344 * @syscap SystemCapability.Utils.Lang 345 * @crossplatform 346 * @since 10 347 */ 348 /** 349 * Name of the property key which will be used for the cdata. 350 * 351 * @syscap SystemCapability.Utils.Lang 352 * @crossplatform 353 * @atomicservice 354 * @since 11 355 */ 356 cdataKey: string; 357 /** 358 * Name of the property key which will be used for the doctype. 359 * 360 * @syscap SystemCapability.Utils.Lang 361 * @since 8 362 */ 363 /** 364 * Name of the property key which will be used for the doctype. 365 * 366 * @syscap SystemCapability.Utils.Lang 367 * @crossplatform 368 * @since 10 369 */ 370 /** 371 * Name of the property key which will be used for the doctype. 372 * 373 * @syscap SystemCapability.Utils.Lang 374 * @crossplatform 375 * @atomicservice 376 * @since 11 377 */ 378 doctypeKey: string; 379 /** 380 * Name of the property key which will be used for the comment. 381 * 382 * @syscap SystemCapability.Utils.Lang 383 * @since 8 384 */ 385 /** 386 * Name of the property key which will be used for the comment. 387 * 388 * @syscap SystemCapability.Utils.Lang 389 * @crossplatform 390 * @since 10 391 */ 392 /** 393 * Name of the property key which will be used for the comment. 394 * 395 * @syscap SystemCapability.Utils.Lang 396 * @crossplatform 397 * @atomicservice 398 * @since 11 399 */ 400 commentKey: string; 401 /** 402 * Name of the property key which will be used for the parent. 403 * 404 * @syscap SystemCapability.Utils.Lang 405 * @since 8 406 */ 407 /** 408 * Name of the property key which will be used for the parent. 409 * 410 * @syscap SystemCapability.Utils.Lang 411 * @crossplatform 412 * @since 10 413 */ 414 /** 415 * Name of the property key which will be used for the parent. 416 * 417 * @syscap SystemCapability.Utils.Lang 418 * @crossplatform 419 * @atomicservice 420 * @since 11 421 */ 422 parentKey: string; 423 /** 424 * Name of the property key which will be used for the type. 425 * 426 * @syscap SystemCapability.Utils.Lang 427 * @since 8 428 */ 429 /** 430 * Name of the property key which will be used for the type. 431 * 432 * @syscap SystemCapability.Utils.Lang 433 * @crossplatform 434 * @since 10 435 */ 436 /** 437 * Name of the property key which will be used for the type. 438 * 439 * @syscap SystemCapability.Utils.Lang 440 * @crossplatform 441 * @atomicservice 442 * @since 11 443 */ 444 typeKey: string; 445 /** 446 * Name of the property key which will be used for the name. 447 * 448 * @syscap SystemCapability.Utils.Lang 449 * @since 8 450 */ 451 /** 452 * Name of the property key which will be used for the name. 453 * 454 * @syscap SystemCapability.Utils.Lang 455 * @crossplatform 456 * @since 10 457 */ 458 /** 459 * Name of the property key which will be used for the name. 460 * 461 * @syscap SystemCapability.Utils.Lang 462 * @crossplatform 463 * @atomicservice 464 * @since 11 465 */ 466 nameKey: string; 467 /** 468 * Name of the property key which will be used for the elements. 469 * 470 * @syscap SystemCapability.Utils.Lang 471 * @since 8 472 */ 473 /** 474 * Name of the property key which will be used for the elements. 475 * 476 * @syscap SystemCapability.Utils.Lang 477 * @crossplatform 478 * @since 10 479 */ 480 /** 481 * Name of the property key which will be used for the elements. 482 * 483 * @syscap SystemCapability.Utils.Lang 484 * @crossplatform 485 * @atomicservice 486 * @since 11 487 */ 488 elementsKey: string; 489 } 490 491 /** 492 * ConvertXML representation refers to extensible markup language. 493 * 494 * @syscap SystemCapability.Utils.Lang 495 * @since 8 496 * @name ConvertXML 497 */ 498 /** 499 * ConvertXML representation refers to extensible markup language. 500 * 501 * @syscap SystemCapability.Utils.Lang 502 * @crossplatform 503 * @since 10 504 * @name ConvertXML 505 */ 506 /** 507 * ConvertXML representation refers to extensible markup language. 508 * 509 * @syscap SystemCapability.Utils.Lang 510 * @crossplatform 511 * @atomicservice 512 * @since 11 513 */ 514 class ConvertXML { 515 /** 516 * To convert XML text to JavaScript object. 517 * 518 * @param { string } xml - xml xml The xml text to be converted. 519 * @param { ConvertOptions } options - options option Option Inputted by user to set. 520 * @returns { Object } Returns a JavaScript object converting from XML text. 521 * @syscap SystemCapability.Utils.Lang 522 * @since 8 523 * @deprecated since 9 524 * @useinstead ohos.convertxml.ConvertXML.convertToJSObject 525 */ 526 convert(xml: string, options?: ConvertOptions): Object; 527 528 /** 529 * To convert XML text to JavaScript object. 530 * 531 * @param { string } xml - xml xml The xml text to be converted. 532 * @param { ConvertOptions } [options] - options option Option Inputted by user to set. 533 * @returns { Object } Returns a JavaScript object converting from XML text. 534 * @throws { BusinessError } 401 - Parameter error. Possible causes: 535 * 1.Mandatory parameters are left unspecified; 536 * 2.Incorrect parameter types. 537 * @throws { BusinessError } 10200002 - Invalid xml string. 538 * @syscap SystemCapability.Utils.Lang 539 * @since 9 540 */ 541 /** 542 * To convert XML text to JavaScript object. 543 * 544 * @param { string } xml - xml xml The xml text to be converted. 545 * @param { ConvertOptions } [options] - options option Option Inputted by user to set. 546 * @returns { Object } Returns a JavaScript object converting from XML text. 547 * @throws { BusinessError } 401 - Parameter error. Possible causes: 548 * 1.Mandatory parameters are left unspecified; 549 * 2.Incorrect parameter types. 550 * @throws { BusinessError } 10200002 - Invalid xml string. 551 * @syscap SystemCapability.Utils.Lang 552 * @crossplatform 553 * @since 10 554 */ 555 /** 556 * To convert XML text to JavaScript object. 557 * 558 * @param { string } xml - xml xml The xml text to be converted. 559 * @param { ConvertOptions } [options] - options option Option Inputted by user to set. 560 * @returns { Object } Returns a JavaScript object converting from XML text. 561 * @throws { BusinessError } 401 - Parameter error. Possible causes: 562 * 1.Mandatory parameters are left unspecified; 563 * 2.Incorrect parameter types. 564 * @throws { BusinessError } 10200002 - Invalid xml string. 565 * @syscap SystemCapability.Utils.Lang 566 * @crossplatform 567 * @atomicservice 568 * @since 11 569 */ 570 convertToJSObject(xml: string, options?: ConvertOptions): Object; 571 } 572} 573export default xml; 574