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 * The convertxml module provides utilities for converting XML text to Javascript object. 18 * 19 * @namespace xml 20 * @syscap SystemCapability.Utils.Lang 21 * @since 8 22 */ 23/** 24 * The convertxml module provides utilities for converting XML text to Javascript object. 25 * 26 * @namespace xml 27 * @syscap SystemCapability.Utils.Lang 28 * @crossplatform 29 * @since 10 30 */ 31declare namespace xml { 32 interface ConvertOptions { 33 /** 34 * Whether to trim whitespace characters that may exist before and after the text, default false. 35 * 36 * @syscap SystemCapability.Utils.Lang 37 * @since 8 38 */ 39 /** 40 * Whether to trim whitespace characters that may exist before and after the text, default false. 41 * 42 * @syscap SystemCapability.Utils.Lang 43 * @crossplatform 44 * @since 10 45 */ 46 trim: boolean; 47 /** 48 * Whether to ignore writing declaration directives of xml. 49 * 50 * @syscap SystemCapability.Utils.Lang 51 * @since 8 52 */ 53 /** 54 * Whether to ignore writing declaration directives of xml. 55 * 56 * @syscap SystemCapability.Utils.Lang 57 * @crossplatform 58 * @since 10 59 */ 60 ignoreDeclaration?: boolean; 61 /** 62 * Whether to ignore writing processing instruction of xml. 63 * 64 * @syscap SystemCapability.Utils.Lang 65 * @since 8 66 */ 67 /** 68 * Whether to ignore writing processing instruction of xml. 69 * 70 * @syscap SystemCapability.Utils.Lang 71 * @crossplatform 72 * @since 10 73 */ 74 ignoreInstruction?: boolean; 75 /** 76 * Whether to print attributes across multiple lines and indent them. 77 * 78 * @syscap SystemCapability.Utils.Lang 79 * @since 8 80 */ 81 /** 82 * Whether to print attributes across multiple lines and indent them. 83 * 84 * @syscap SystemCapability.Utils.Lang 85 * @crossplatform 86 * @since 10 87 */ 88 ignoreAttributes?: boolean; 89 /** 90 * Whether to ignore writing comments of the elements. 91 * 92 * @syscap SystemCapability.Utils.Lang 93 * @since 8 94 */ 95 /** 96 * Whether to ignore writing comments of the elements. 97 * 98 * @syscap SystemCapability.Utils.Lang 99 * @crossplatform 100 * @since 10 101 */ 102 ignoreComment?: boolean; 103 /** 104 * Whether to ignore writing CDATA of the elements. 105 * 106 * @syscap SystemCapability.Utils.Lang 107 * @since 8 108 */ 109 /** 110 * Whether to ignore writing CDATA of the elements. 111 * 112 * @syscap SystemCapability.Utils.Lang 113 * @crossplatform 114 * @since 10 115 */ 116 ignoreCDATA?: boolean; 117 /** 118 * Whether to ignore writing Doctype of the elements. 119 * 120 * @syscap SystemCapability.Utils.Lang 121 * @since 8 122 */ 123 /** 124 * Whether to ignore writing Doctype of the elements. 125 * 126 * @syscap SystemCapability.Utils.Lang 127 * @crossplatform 128 * @since 10 129 */ 130 ignoreDoctype?: boolean; 131 /** 132 * Whether to ignore writing texts of the elements. 133 * 134 * @syscap SystemCapability.Utils.Lang 135 * @since 8 136 */ 137 /** 138 * Whether to ignore writing texts of the elements. 139 * 140 * @syscap SystemCapability.Utils.Lang 141 * @crossplatform 142 * @since 10 143 */ 144 ignoreText?: boolean; 145 /** 146 * Name of the property key which will be used for the declaration. 147 * 148 * @syscap SystemCapability.Utils.Lang 149 * @since 8 150 */ 151 /** 152 * Name of the property key which will be used for the declaration. 153 * 154 * @syscap SystemCapability.Utils.Lang 155 * @crossplatform 156 * @since 10 157 */ 158 declarationKey: string; 159 /** 160 * Name of the property key which will be used for the processing instruction. 161 * 162 * @syscap SystemCapability.Utils.Lang 163 * @since 8 164 */ 165 /** 166 * Name of the property key which will be used for the processing instruction. 167 * 168 * @syscap SystemCapability.Utils.Lang 169 * @crossplatform 170 * @since 10 171 */ 172 instructionKey: string; 173 /** 174 * Name of the property key which will be used for the attributes. 175 * 176 * @syscap SystemCapability.Utils.Lang 177 * @since 8 178 */ 179 /** 180 * Name of the property key which will be used for the attributes. 181 * 182 * @syscap SystemCapability.Utils.Lang 183 * @crossplatform 184 * @since 10 185 */ 186 attributesKey: string; 187 /** 188 * Name of the property key which will be used for the text. 189 * 190 * @syscap SystemCapability.Utils.Lang 191 * @since 8 192 */ 193 /** 194 * Name of the property key which will be used for the text. 195 * 196 * @syscap SystemCapability.Utils.Lang 197 * @crossplatform 198 * @since 10 199 */ 200 textKey: string; 201 /** 202 * Name of the property key which will be used for the cdata. 203 * 204 * @syscap SystemCapability.Utils.Lang 205 * @since 8 206 */ 207 /** 208 * Name of the property key which will be used for the cdata. 209 * 210 * @syscap SystemCapability.Utils.Lang 211 * @crossplatform 212 * @since 10 213 */ 214 cdataKey: string; 215 /** 216 * Name of the property key which will be used for the doctype. 217 * 218 * @syscap SystemCapability.Utils.Lang 219 * @since 8 220 */ 221 /** 222 * Name of the property key which will be used for the doctype. 223 * 224 * @syscap SystemCapability.Utils.Lang 225 * @crossplatform 226 * @since 10 227 */ 228 doctypeKey: string; 229 /** 230 * Name of the property key which will be used for the comment. 231 * 232 * @syscap SystemCapability.Utils.Lang 233 * @since 8 234 */ 235 /** 236 * Name of the property key which will be used for the comment. 237 * 238 * @syscap SystemCapability.Utils.Lang 239 * @crossplatform 240 * @since 10 241 */ 242 commentKey: string; 243 /** 244 * Name of the property key which will be used for the parent. 245 * 246 * @syscap SystemCapability.Utils.Lang 247 * @since 8 248 */ 249 /** 250 * Name of the property key which will be used for the parent. 251 * 252 * @syscap SystemCapability.Utils.Lang 253 * @crossplatform 254 * @since 10 255 */ 256 parentKey: string; 257 /** 258 * Name of the property key which will be used for the type. 259 * 260 * @syscap SystemCapability.Utils.Lang 261 * @since 8 262 */ 263 /** 264 * Name of the property key which will be used for the type. 265 * 266 * @syscap SystemCapability.Utils.Lang 267 * @crossplatform 268 * @since 10 269 */ 270 typeKey: string; 271 /** 272 * Name of the property key which will be used for the name. 273 * 274 * @syscap SystemCapability.Utils.Lang 275 * @since 8 276 */ 277 /** 278 * Name of the property key which will be used for the name. 279 * 280 * @syscap SystemCapability.Utils.Lang 281 * @crossplatform 282 * @since 10 283 */ 284 nameKey: string; 285 /** 286 * Name of the property key which will be used for the elements. 287 * 288 * @syscap SystemCapability.Utils.Lang 289 * @since 8 290 */ 291 /** 292 * Name of the property key which will be used for the elements. 293 * 294 * @syscap SystemCapability.Utils.Lang 295 * @crossplatform 296 * @since 10 297 */ 298 elementsKey: string; 299 } 300 301 /** 302 * ConvertXML representation refers to extensible markup language. 303 * 304 * @syscap SystemCapability.Utils.Lang 305 * @since 8 306 * @name ConvertXML 307 */ 308 /** 309 * ConvertXML representation refers to extensible markup language. 310 * 311 * @syscap SystemCapability.Utils.Lang 312 * @crossplatform 313 * @since 10 314 * @name ConvertXML 315 */ 316 class ConvertXML { 317 /** 318 * To convert XML text to JavaScript object. 319 * 320 * @param { string } xml - xml xml The xml text to be converted. 321 * @param { ConvertOptions } options - options option Option Inputted by user to set. 322 * @returns { Object } Returns a JavaScript object converting from XML text. 323 * @syscap SystemCapability.Utils.Lang 324 * @since 8 325 * @deprecated since 9 326 * @useinstead ohos.convertxml.ConvertXML.convertToJSObject 327 */ 328 convert(xml: string, options?: ConvertOptions): Object; 329 330 /** 331 * To convert XML text to JavaScript object. 332 * 333 * @param { string } xml - xml xml The xml text to be converted. 334 * @param { ConvertOptions } options - options option Option Inputted by user to set. 335 * @returns { Object } Returns a JavaScript object converting from XML text. 336 * @throws { BusinessError } 401 - if the input parameters are invalid. 337 * @throws { BusinessError } 10200002 - Invalid xml string. 338 * @syscap SystemCapability.Utils.Lang 339 * @since 9 340 */ 341 /** 342 * To convert XML text to JavaScript object. 343 * 344 * @param { string } xml - xml xml The xml text to be converted. 345 * @param { ConvertOptions } options - options option Option Inputted by user to set. 346 * @returns { Object } Returns a JavaScript object converting from XML text. 347 * @throws { BusinessError } 401 - if the input parameters are invalid. 348 * @throws { BusinessError } 10200002 - Invalid xml string. 349 * @syscap SystemCapability.Utils.Lang 350 * @crossplatform 351 * @since 10 352 */ 353 convertToJSObject(xml: string, options?: ConvertOptions): Object; 354 } 355} 356export default xml; 357