> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
```
## System Capabilities
SystemCapability.Security.AccessToken
## abilityAccessCtrl.createAtManager
createAtManager(): AtManager
Creates an **AtManager** instance, which is used for ability access control.
| permissionName | string | Yes| Name of the permission to grant.|
| permissionFlag | number | Yes| Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed.|
| permissionName | string | Yes| Name of the permission to grant.|
| permissionFlag | number | Yes| Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed.|
| callback | AsyncCallback<number> | Yes| Callback used to return the result.|
| permissionName | string | Yes| Name of the permission to revoke.|
| permissionFlag | number | Yes| Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed.|
| permissionName | string | Yes| Name of the permission to revoke.|
| permissionFlag | number | Yes| Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed.|
| callback | AsyncCallback<number> | Yes| Callback used to return the result.|
>The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> **NOTE**
>The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p9845227114216"><aname="p9845227114216"></a><aname="p9845227114216"></a>Whether to trim the whitespace characters before and after the text. The default value is <strongid="b6928115525311"><aname="b6928115525311"></a><aname="b6928115525311"></a>false</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p4833610345"><aname="p4833610345"></a><aname="p4833610345"></a>Whether to ignore the XML declaration. The default value is <strongid="b1986182720517"><aname="b1986182720517"></a><aname="b1986182720517"></a>false</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p142083683419"><aname="p142083683419"></a><aname="p142083683419"></a>Whether to ignore the XML processing instruction. The default value is <strongid="b9507112714198"><aname="b9507112714198"></a><aname="b9507112714198"></a>false</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p15291036153412"><aname="p15291036153412"></a><aname="p15291036153412"></a>Whether to print attributes across multiple lines and indent attributes. The default value is <strongid="b214910972014"><aname="b214910972014"></a><aname="b214910972014"></a>false</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p8391736163418"><aname="p8391736163418"></a><aname="p8391736163418"></a>Whether to ignore element comments. The default value is <strongid="b12921132182012"><aname="b12921132182012"></a><aname="b12921132182012"></a>false</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p28461623102316"><aname="p28461623102316"></a><aname="p28461623102316"></a>Whether to ignore the element's CDATA information. The default value is <strongid="b8400141332617"><aname="b8400141332617"></a><aname="b8400141332617"></a>false</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p462436183414"><aname="p462436183414"></a><aname="p462436183414"></a>Whether to ignore the element's <strongid="b1644365410213"><aname="b1644365410213"></a><aname="b1644365410213"></a>Doctype</strong> information. The default value is <strongid="b38201991221"><aname="b38201991221"></a><aname="b38201991221"></a>false</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p67643663417"><aname="p67643663417"></a><aname="p67643663417"></a>Whether to ignore the element's text information. The default value is <strongid="b21731940182214"><aname="b21731940182214"></a><aname="b21731940182214"></a>false</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p1461412852710"><aname="p1461412852710"></a><aname="p1461412852710"></a>Name of the attribute key for <strongid="b7197102842416"><aname="b7197102842416"></a><aname="b7197102842416"></a>declaration</strong> in the output object. The default value is <strongid="b92387720242"><aname="b92387720242"></a><aname="b92387720242"></a>_declaration</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p336283815279"><aname="p336283815279"></a><aname="p336283815279"></a>Name of the attribute key for <strongid="b978125313248"><aname="b978125313248"></a><aname="b978125313248"></a>instruction</strong> in the output object. The default value is <strongid="b2459142611"><aname="b2459142611"></a><aname="b2459142611"></a>_instruction</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p7608142813588"><aname="p7608142813588"></a><aname="p7608142813588"></a>Name of the attribute key for <strongid="b9204185112618"><aname="b9204185112618"></a><aname="b9204185112618"></a>attributes</strong> in the output object. The default value is <strongid="b392414585262"><aname="b392414585262"></a><aname="b392414585262"></a>_attributes</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p0344122145814"><aname="p0344122145814"></a><aname="p0344122145814"></a>Name of the attribute key for <strongid="b851743532718"><aname="b851743532718"></a><aname="b851743532718"></a>text</strong> in the output object. The default value is <strongid="b350917477273"><aname="b350917477273"></a><aname="b350917477273"></a>_text</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p475618155581"><aname="p475618155581"></a><aname="p475618155581"></a>Name of the attribute key for <strongid="b26841859132720"><aname="b26841859132720"></a><aname="b26841859132720"></a>CDATA</strong> in the output object. The default value is <strongid="b1586013185285"><aname="b1586013185285"></a><aname="b1586013185285"></a>_cdata</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p0979042154918"><aname="p0979042154918"></a><aname="p0979042154918"></a>Name of the attribute key for <strongid="b34439596306"><aname="b34439596306"></a><aname="b34439596306"></a>Doctype</strong> in the output object. The default value is <strongid="b022043913329"><aname="b022043913329"></a><aname="b022043913329"></a>_doctype</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p748535519570"><aname="p748535519570"></a><aname="p748535519570"></a>Name of the attribute key for <strongid="b12533205423211"><aname="b12533205423211"></a><aname="b12533205423211"></a>comment</strong> in the output object. The default value is <strongid="b105967633313"><aname="b105967633313"></a><aname="b105967633313"></a>_comment</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p1599716428492"><aname="p1599716428492"></a><aname="p1599716428492"></a>Name of the attribute key for <strongid="b18469936103317"><aname="b18469936103317"></a><aname="b18469936103317"></a>parent</strong> in the output object. The default value is <strongid="b5277443163312"><aname="b5277443163312"></a><aname="b5277443163312"></a>_parent</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p1568738115715"><aname="p1568738115715"></a><aname="p1568738115715"></a>Name of the attribute key for <strongid="b562120374361"><aname="b562120374361"></a><aname="b562120374361"></a>type</strong> in the output object. The default value is <strongid="b1182815436368"><aname="b1182815436368"></a><aname="b1182815436368"></a>_type</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p159295216567"><aname="p159295216567"></a><aname="p159295216567"></a>Name of the attribute key for <strongid="b959742613717"><aname="b959742613717"></a><aname="b959742613717"></a>name</strong> in the output object. The default value is <strongid="b2605034203717"><aname="b2605034203717"></a><aname="b2605034203717"></a>_name</strong>.</p>
<tdclass="cellrowborder"valign="top"width="55.26%"headers="mcps1.1.5.1.4 "><pid="p62794384910"><aname="p62794384910"></a><aname="p62794384910"></a>Name of the attribute key for <strongid="b116698498376"><aname="b116698498376"></a><aname="b116698498376"></a>elements</strong> in the output object. The default value is <strongid="b1054145814374"><aname="b1054145814374"></a><aname="b1054145814374"></a>_elements</strong>.</p>
Obtains the fault information about the current process. This method uses a callback to return the fault information array obtained, which contains a maximum of 10 pieces of fault information.
| callback | AsyncCallbackArray<Array<[FaultLogInfo](#faultloginfo)>> | Yes| Callback used to return the fault information array. <br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned.
| callback | AsyncCallbackArray<Array<[FaultLogInfo](#faultloginfo)>> | Yes| Callback used to return the fault information array. <br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned.
Obtains the fault information about the current process. This method uses a promise to return the fault information array obtained, which contains a maximum of 10 pieces of fault information.
| Promise<Array<[FaultLogInfo](#faultloginfo)>> | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**. <br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.|
- Return value
| Type| Description|
| -------- | -------- |
| Promise<Array<[FaultLogInfo](#faultloginfo)>> | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**. <br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.|
**Example**
- Example
```
let value = await faultLogger.querySelfFaultLog(faultlogger.FaultType.JS_CRASH);
>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
<tdclass="cellrowborder"valign="top"width="47.94%"headers="mcps1.1.6.1.5 "><pid="p14455857115415"><aname="p14455857115415"></a><aname="p14455857115415"></a>Effective group identifier (EGID) of a process.</p>
<tdclass="cellrowborder"valign="top"width="47.94%"headers="mcps1.1.6.1.5 "><pid="p94821125817"><aname="p94821125817"></a><aname="p94821125817"></a>Effective user identifier (EUID) of a process.</p>
<tdclass="cellrowborder"valign="top"width="47.94%"headers="mcps1.1.6.1.5 "><pid="p6455857135420"><aname="p6455857135420"></a><aname="p6455857135420"></a>Group identifier (GID) of a process.</p>
<tdclass="cellrowborder"valign="top"width="47.94%"headers="mcps1.1.6.1.5 "><pid="p1545610579549"><aname="p1545610579549"></a><aname="p1545610579549"></a>User identifier (UID) of a process.</p>
<tdclass="cellrowborder"valign="top"width="47.94%"headers="mcps1.1.6.1.5 "><pid="p12456257145411"><aname="p12456257145411"></a><aname="p12456257145411"></a>Array with supplementary group IDs.</p>
<tdclass="cellrowborder"valign="top"width="47.94%"headers="mcps1.1.6.1.5 "><pid="p1545612577543"><aname="p1545612577543"></a><aname="p1545612577543"></a>Process ID (PID) of a process.</p>
<tdclass="cellrowborder"valign="top"width="47.94%"headers="mcps1.1.6.1.5 "><pid="p2050111216567"><aname="p2050111216567"></a><aname="p2050111216567"></a>Parent process ID (PPID) of a process.</p>
<tdclass="cellrowborder"valign="top"width="47.94%"headers="mcps1.1.6.1.5 "><pid="p16834532191011"><aname="p16834532191011"></a><aname="p16834532191011"></a>Thread ID (TID) of a process.</p>
</td>
</tr>
</tbody>
</table>
## ChildProcess<a name="section6521387200"></a>
Provides methods for a process to obtain the standard input and output of its child processes, send signals, and close its child processes.
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p7678105615402"><aname="p7678105615402"></a><aname="p7678105615402"></a>PID of the child process.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p19949102034110"><aname="p19949102034110"></a><aname="p19949102034110"></a>PPID of the child process.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p348319442351"><aname="p348319442351"></a><aname="p348319442351"></a>Exit code of the child process.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p518611015431"><aname="p518611015431"></a><aname="p518611015431"></a>Whether the parent process successfully sends a signal to the child process to terminate it.</p>
<td class="cellrowborder" valign="top" width="74.21%" headers="mcps1.1.3.1.2 "><p id="p6786118144419"><a name="p6786118144419"></a><a name="p6786118144419"></a>Promise used to return the exit code of the child process.</p>
</td>
</tr>
</tbody>
</table>
| Type| Description|
| -------- | -------- |
| Promise<number> | Promise used to return the exit code of the child process.|
<td class="cellrowborder" valign="top" width="69.02000000000001%" headers="mcps1.1.3.1.2 "><p id="p83512284717"><a name="p83512284717"></a><a name="p83512284717"></a>Promise used to return the standard output in a Uint8Array.</p>
</td>
</tr>
</tbody>
</table>
| Type| Description|
| -------- | -------- |
| Promise<Uint8Array> | Promise used to return the standard output in a Uint8Array.|
<td class="cellrowborder" valign="top" width="69.64%" headers="mcps1.1.3.1.2 "><p id="p9672144081314"><a name="p9672144081314"></a><a name="p9672144081314"></a>Promise used to return the standard error output in a Uint8Array.</p>
</td>
</tr>
</tbody>
</table>
| Type| Description|
| -------- | -------- |
| Promise<Uint8Array> | Promise used to return the standard error output in a Uint8Array.|
- Example
**Example**
```
var child = process.runCmd('madir test.text');
var result = child.wait();
child.getErrorOutput.then(val=>{
console.log("child.getErrorOutput= " + val);
})
```
```
var child = process.runCmd('madir test.text');
var result = child.wait();
child.getErrorOutput.then(val=>{
console.log("child.getErrorOutput= " + val);
})
```
### close<a name="section28221257121518"></a>
### close
close\(\): void
close(): void
Closes the child process in running.
- Example
**Example**
```
var child = process.runCmd('sleep 5; ls');
child.close();
```
```
var child = process.runCmd('sleep 5; ls');
child.close();
```
### kill<a name="section9528134162114"></a>
### kill
kill\(signal: number | string\): void
kill(signal: number | string): void
Sends a signal to the specified child process to terminate it.
<td class="cellrowborder" valign="top" width="55.26%" headers="mcps1.2.5.1.4 "><p id="p3958113385114"><a name="p3958113385114"></a><a name="p3958113385114"></a>Maximum running time (in ms) of the child process. When the running time of the child process exceeds the value of this parameter, the parent process sends a <strong id="b16581181141220"><a name="b16581181141220"></a><a name="b16581181141220"></a>killSignal</strong> to the child process to terminate it. The default value is <strong id="b83520247124"><a name="b83520247124"></a><a name="b83520247124"></a>0</strong>.</p>
<td class="cellrowborder" valign="top" width="55.26%" headers="mcps1.2.5.1.4 "><p id="p6975134106"><a name="p6975134106"></a><a name="p6975134106"></a>Signal sent to the child process when the running time of a child process exceeds the timeout period. The default value is <strong id="b112802023141411"><a name="b112802023141411"></a><a name="b112802023141411"></a>SIGTERM</strong>.</p>
<td class="cellrowborder" valign="top" width="55.26%" headers="mcps1.2.5.1.4 "><p id="p610211102610"><a name="p610211102610"></a><a name="p610211102610"></a>Maximum buffer size for the standard input and output of the child process. When the size is exceeded, the child process will be terminated. The default value is <strong id="b17684182611617"><a name="b17684182611617"></a><a name="b17684182611617"></a>1024 * 1024</strong>.</p>
| name | string | Yes| Environment variable name.|
**Return value**
| Type| Description|
| -------- | -------- |
| string | Value of the environment variable.|
**Example**
```
var pres = process.getEnvironmentVar("PATH")
```
## process.runCmd
runCmd(command: string, options?: { timeout : number, killSignal : number | string, maxBuffer : number }) : ChildProcess
Forks a new process to run a shell command and returns the **ChildProcess** object.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| command | string | Yes| Shell command to run.|
| options | Object | No| Related parameters.|
**Table 1** options
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| timeout | number | No| Maximum running time (in ms) of the child process. When the running time of the child process exceeds the value of this parameter, the parent process sends a **killSignal** to the child process to terminate it. The default value is **0**.|
| killSignal | number \| string | No| Signal sent to the child process when the running time of a child process exceeds the timeout period. The default value is **SIGTERM**.|
| maxBuffer | number | No| Maximum buffer size for the standard input and output of the child process. When the size is exceeded, the child process will be terminated. The default value is **1024 \* 1024**.|
<td class="cellrowborder" valign="top" width="52.38%" headers="mcps1.1.5.1.4 "><p id="p137713153495"><a name="p137713153495"></a><a name="p137713153495"></a>Type of the events to store. </p>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p14142749591"><a name="p14142749591"></a><a name="p14142749591"></a>Type of the event to delete.</p>
<td class="cellrowborder" valign="top" width="78.97999999999999%" headers="mcps1.1.3.1.2 "><p id="p17605112914167"><a name="p17605112914167"></a><a name="p17605112914167"></a>Running time of the process, in seconds.</p>
</td>
</tr>
</tbody>
</table>
| Type| Description|
| -------- | -------- |
| number | Running time of the process, in seconds.|
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p4206174101910"><a name="p4206174101910"></a><a name="p4206174101910"></a>PID of the process, to which the signal will be sent.</p>
<td class="cellrowborder" valign="top" width="79.01%" headers="mcps1.1.3.1.2 "><p id="p7207194141914"><a name="p7207194141914"></a><a name="p7207194141914"></a>Returns <strong id="b5691160144712"><a name="b5691160144712"></a><a name="b5691160144712"></a>true</strong> if the signal is sent successfully; returns <strong id="b5409191810479"><a name="b5409191810479"></a><a name="b5409191810479"></a>false</strong> otherwise.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var pres = process.pid
var result = that.kill(pres, 28)
```
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pid | number | Yes| PID of the process, to which the signal will be sent.|
| signal | number | Yes| Signal to send.|
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the signal is sent successfully; returns **false** otherwise.|
>The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import<a name="section2080512344162"></a>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p72131224114411"><aname="p72131224114411"></a><aname="p72131224114411"></a>Protocol in the URI.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p12865829133514"><aname="p12865829133514"></a><aname="p12865829133514"></a>User information in the URI.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p737414373372"><aname="p737414373372"></a><aname="p737414373372"></a>Host name (without the port number) in the URI.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p3153171613242"><aname="p3153171613242"></a><aname="p3153171613242"></a>Port number in the URI.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p18565132916244"><aname="p18565132916244"></a><aname="p18565132916244"></a>Path in the URI.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p1299814373714"><aname="p1299814373714"></a><aname="p1299814373714"></a>Query part in the URI.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p18527842143718"><aname="p18527842143718"></a><aname="p18527842143718"></a>Fragment part in the URI.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p1421614403377"><aname="p1421614403377"></a><aname="p1421614403377"></a>Authority part in the URI.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p363383518374"><aname="p363383518374"></a><aname="p363383518374"></a>Scheme-specific part in the URI.</p>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| init | string[][] \| Record<string, string> \| string \| URLSearchParams | No| Input parameter objects, which include the following: <br/>- **string[][]**: two-dimensional string array<br/>- **Record<string, string>**: list of objects<br/>- **string**: string<br/>- **URLSearchParams**: object|
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| init | string[][] \| Record<string, string> \| string \| URLSearchParams | No| Input parameter objects, which include the following: <br/>- **string[][]**: two-dimensional string array<br/>- **Record<string, string>**: list of objects<br/>- **string**: string<br/>- **URLSearchParams**: object|
**Example**
- Example
```
var objectParams = new URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]);
var objectParams1 = new URLSearchParams({"fod" : 1 , "bard" : 2});
var objectParams2 = new URLSearchParams('?fod=1&bard=2');
var urlObject = new URL('https://developer.mozilla.org/?fod=1&bard=2');
var params = new URLSearchParams(urlObject .search);
```
```
var objectParams = new URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]);
var objectParams1 = new URLSearchParams({"fod" : 1 , "bard" : 2});
var objectParams2 = new URLSearchParams('?fod=1&bard=2');
var urlObject = new URL('https://developer.mozilla.org/?fod=1&bard=2');
var params = new URLSearchParams(urlObject .search);
Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively.
- Return values
| Type| Description|
| -------- | -------- |
| IterableIterator<[string, string]> | An ES6 iterator.|
**Return value**
| Type| Description|
| -------- | -------- |
| IterableIterator<[string, string]> | An ES6 iterator.|
- Example
```
var searchParamsObject = new URLSearchParams("keyName1=valueName1&keyName2=valueName2");
for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs
console.log(pair[0]+ ', '+ pair[1]);
}
```
**Example**
```
var searchParamsObject = new URLSearchParams("keyName1=valueName1&keyName2=valueName2");
for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs
Sets the value for a key. If key-value pairs matching the specified key exist, the value of the first key-value pair will be set to the specified value and other key-value pairs will be deleted. Otherwise, the key-value pair will be appended to the query string.
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key of the value to set.|
| value | string | Yes| Value to set.|
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Key of the value to set.|
| value | string | Yes| Value to set.|
- Example
```
let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new URLSearchParams(urlObject.search.slice(1));
paramsObject.set('baz', 3); // Add a third parameter.
```
**Example**
```
let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new URLSearchParams(urlObject.search.slice(1));
paramsObject.set('baz', 3); // Add a third parameter.
```
### sort
...
...
@@ -229,13 +249,13 @@ sort(): void
Sorts all key-value pairs contained in this object based on the Unicode code points of the keys and returns undefined. This method uses a stable sorting algorithm, that is, the relative order between key-value pairs with equal keys is retained.
**Example**
- Example
```
var searchParamsObject = new URLSearchParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object
searchParamsObject.sort(); // Sort the key/value pairs
console.log(searchParamsObject.toString()); // Display the sorted query string // Output a=9&b=2&c=3&d=4
```
```
var searchParamsObject = new URLSearchParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object
searchParamsObject.sort(); // Sort the key/value pairs
console.log(searchParamsObject.toString()); // Display the sorted query string // Output a=9&b=2&c=3&d=4
Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and the first and second fields of each array are the key and value respectively.
**Return value**
- Return values
| Type| Description|
| -------- | -------- |
| IterableIterator<[string, string]> | An ES6 iterator.|
| base | string \| URL | No| Input parameter, which can be any of the following: <br/>- **string**: string<br/>- **URL**: string or object|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| url | string | Yes| Input object.|
| base | string \| URL | No| Input parameter, which can be any of the following: <br/>- **string**: string<br/>- **URL**: string or object|
**Example**
- Example
```
var mm = 'http://username:password@host:8080';
var a = new URL("/", mm); // Output 'http://username:password@host:8080/';
var b = new URL(mm); // Output 'http://username:password@host:8080/';
new URL('path/path1', b); // Output 'http://username:password@host:8080/path/path1';
var c = new URL('/path/path1', b); // Output 'http://username:password@host:8080/path/path1';
new URL('/path/path1', c); // Output 'http://username:password@host:8080/path/path1';
new URL('/path/path1', a); // Output 'http://username:password@host:8080/path/path1';
new URL('/path/path1', "https://www.exampleUrl/fr-FR/toto"); // Output https://www.exampleUrl/path/path1
new URL('/path/path1', ''); // Raises a TypeError exception as '' is not a valid URL
new URL('/path/path1'); // Raises a TypeError exception as '/path/path1' is not a valid URL
new URL('http://www.shanxi.com', ); // Output http://www.shanxi.com/
new URL('http://www.shanxi.com', b); // Output http://www.shanxi.com/
```
```
var mm = 'http://username:password@host:8080';
var a = new URL("/", mm); // Output 'http://username:password@host:8080/';
var b = new URL(mm); // Output 'http://username:password@host:8080/';
new URL('path/path1', b); // Output 'http://username:password@host:8080/path/path1';
var c = new URL('/path/path1', b); // Output 'http://username:password@host:8080/path/path1';
new URL('/path/path1', c); // Output 'http://username:password@host:8080/path/path1';
new URL('/path/path1', a); // Output 'http://username:password@host:8080/path/path1';
new URL('/path/path1', "https://www.exampleUrl/fr-FR/toto"); // Output https://www.exampleUrl/path/path1
new URL('/path/path1', ''); // Raises a TypeError exception as '' is not a valid URL
new URL('/path/path1'); // Raises a TypeError exception as '/path/path1' is not a valid URL
new URL('http://www.shanxi.com', ); // Output http://www.shanxi.com/
new URL('http://www.shanxi.com', b); // Output http://www.shanxi.com/
```
### tostring
...
...
@@ -386,18 +408,18 @@ toString(): string
Converts the parsed URL into a string.
**Return value**
- Return values
| Type| Description|
| -------- | -------- |
| string | Website address in a serialized string.|
| Type| Description|
| -------- | -------- |
| string | Website address in a serialized string.|
**Example**
- Example
```
const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toString()
```
```
const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toString()
```
### toJSON
...
...
@@ -407,15 +429,14 @@ toJSON(): string
Converts the parsed URL into a JSON string.
**Return value**
- Return values
| Type| Description|
| -------- | -------- |
| string | Website address in a serialized string.|
| Type| Description|
| -------- | -------- |
| string | Website address in a serialized string.|
- Example
```
const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toJSON()
```
**Example**
```
const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
<tdclass="cellrowborder"valign="top"width="43.99%"headers="mcps1.1.6.1.5 "><pid="p205212394586"><aname="p205212394586"></a><aname="p205212394586"></a>Object of the worker thread used to communicate with the host thread.</p>
| parentPort | [DedicatedWorkerGlobalScope](#dedicatedworkerglobalscope) | Yes| Yes| Object of the worker thread used to communicate with the host thread.|
## WorkerOptions
Provides options that can be set for the worker to create.
<tdclass="cellrowborder"valign="top"width="43.99%"headers="mcps1.1.6.1.5 "><pid="p1428811192144"><aname="p1428811192144"></a><aname="p1428811192144"></a>Mode in which the worker executes the script.</p>
<tdclass="cellrowborder"valign="top"width="43.99%"headers="mcps1.1.6.1.5 "><pid="p1228991915144"><aname="p1228991915144"></a><aname="p1228991915144"></a>Name of the worker.</p>
</td>
</tr>
</tbody>
</table>
## Worker<a name="section182179935414"></a>
Before using the following methods, you must construct a worker instance. The **worker** class inherits from [EventTarget](#section256019311465).
<td class="cellrowborder" valign="top" width="53.510000000000005%" headers="mcps1.1.5.1.4 "><p id="p361655121112"><a name="p361655121112"></a><a name="p361655121112"></a>URL of the script to be executed by the worker. The script is stored in the <strong id="b1032422614435"><a name="b1032422614435"></a><a name="b1032422614435"></a>workers</strong> directory, which is in the same directory as the <strong id="b7458447164316"><a name="b7458447164316"></a><a name="b7458447164316"></a>pages</strong> directory of the new DevEco Studio project. If the <strong id="b1754142964418"><a name="b1754142964418"></a><a name="b1754142964418"></a>workers</strong> directory does not exist, you need to create it.</p>
<td class="cellrowborder" valign="top" width="53.510000000000005%" headers="mcps1.1.5.1.4 "><p id="p1862255141118"><a name="p1862255141118"></a><a name="p1862255141118"></a>Options that can be set for the worker.</p>
A constructor used to create a **Worker** instance.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| scriptURL | string | Yes| URL of the script to be executed by the worker. The script is stored in the **workers** directory, which is in the same directory as the **pages** directory of the new DevEco Studio project. If the **workers** directory does not exist, you need to create it.|
| options | [WorkerOptions](#workeroptions) | No| Options that can be set for the worker.|
**Return value**
| Type| Description|
| -------- | -------- |
| worker | Returns the **Worker** instance created; returns **undefined** if the **Worker** instance fails to be created.|
**Example**
```
const workerInstance = new worker.Worker("workers/worker.js", {name:"first worker"});
<td class="cellrowborder" valign="top" width="57.79%" headers="mcps1.1.5.1.4 "><p id="p814951171516"><a name="p814951171516"></a><a name="p814951171516"></a>Data to be sent to the worker.</p>
<td class="cellrowborder" valign="top" width="57.79%" headers="mcps1.1.5.1.4 "><p id="p67490772615"><a name="p67490772615"></a><a name="p67490772615"></a><strong id="b562310530116"><a name="b562310530116"></a><a name="b562310530116"></a>ArrayBuffer</strong> instances that can be transferred. The <strong id="b95422281828"><a name="b95422281828"></a><a name="b95422281828"></a>transferList</strong> array cannot contain <strong id="b1223116341821"><a name="b1223116341821"></a><a name="b1223116341821"></a>null</strong>.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
const workerInstance = new worker.Worker("workers/worker.js");
workerInstance.postMessage("hello world");
```
```
const workerInstance = new worker.Worker("workers/worker.js");
var buffer = new ArrayBuffer(8);
workerInstance.postMessage(buffer, [buffer]);
```
### on<a name="section1201327272"></a>
on\(type: string, listener: EventListener\): void
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| message | Object | Yes| Data to be sent to the worker.|
| options | [PostMessageOptions](#postmessageoptions) | No| **ArrayBuffer** instances that can be transferred. The **transferList** array cannot contain **null**.|
**Example**
```
const workerInstance = new worker.Worker("workers/worker.js");
workerInstance.postMessage("hello world");
```
```
const workerInstance= new worker.Worker("workers/worker.js");
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p6143272720"><a name="p6143272720"></a><a name="p6143272720"></a>Type of the event to listen for.</p>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p5173202714"><a name="p5173202714"></a><a name="p5173202714"></a>Callback to invoke when an event of the specified type occurs.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
const workerInstance = new worker.Worker("workers/worker.js")
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p14401409359"><a name="p14401409359"></a><a name="p14401409359"></a>Type of the event to listen for.</p>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p1944074073514"><a name="p1944074073514"></a><a name="p1944074073514"></a>Callback to invoke when an event of the specified type occurs.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
const workerInstance = new worker.Worker("workers/worker.js");
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p20904122918367"><a name="p20904122918367"></a><a name="p20904122918367"></a>Type of the event for which the event listener is removed.</p>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p29042297361"><a name="p29042297361"></a><a name="p29042297361"></a>Callback of the event listener to remove.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
const workerInstance = new worker.Worker("workers/worker.js");
workerInstance.off("alert");
```
### terminate<a name="section17586211104214"></a>
terminate\(\): void
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event for which the event listener is removed.|
| listener | [EventListener](#eventlistener) | No| Callback of the event listener to remove.|
**Example**
```
const workerInstance = new worker.Worker("workers/worker.js");
workerInstance.off("alert");
```
### terminate
terminate(): void
Terminates the worker thread to stop the worker from receiving messages.
- Example
**Example**
```
const workerInstance = new worker.Worker("workers/worker.js")
workerInstance.terminate()
```
```
const workerInstance = new worker.Worker("workers/worker.js")
workerInstance.terminate()
```
### onexit<a name="section1478913292320"></a>
### onexit
onexit?: \(code: number\) =\> void
onexit?: (code: number) => void
Defines the event handler to be called when the worker exits. The handler is executed in the host thread.
const workerInstance = new worker.Worker("workers/worker.js")
workerInstance.onerror = function(e) {
console.log("onerror")
}
```
### onmessage<a name="section516520044515"></a>
onmessage?: \(event: MessageEvent\) =\> void
Defines the event handler to be called when the host thread receives a message created by itself and sent by the worker through the **parentPort.postMessage**. The event handler is executed in the host thread.
const workerInstance = new worker.Worker("workers/worker.js")
workerInstance.onerror = function(e) {
console.log("onerror")
}
```
### onmessage
onmessage?: (event: MessageEvent) => void
Defines the event handler to be called when the host thread receives a message created by itself and sent by the worker through the **parentPort.postMessage**. The event handler is executed in the host thread.
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p440603894519"><a name="p440603894519"></a><a name="p440603894519"></a>Type of the event to listen for.</p>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p19406113874515"><a name="p19406113874515"></a><a name="p19406113874515"></a>Callback to invoke when an event of the specified type occurs.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
const workerInstance = new worker.Worker("workers/worker.js")
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p23739494618"><a name="p23739494618"></a><a name="p23739494618"></a>Type of the event for which the event listener is removed.</p>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p132381754719"><a name="p132381754719"></a><a name="p132381754719"></a>Callback of the event listener to remove.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
const workerInstance = new worker.Worker("workers/worker.js")
Implements communication between the worker thread and the host thread. The **postMessage** API is used to send messages to the host thread, and the **close** API is used to terminate the worker thread. The **DedicatedWorkerGlobalScope** class inherits from [WorkerGlobalScope](#section12882825611).
Implements communication between the worker thread and the host thread. The **postMessage** API is used to send messages to the host thread, and the **close** API is used to terminate the worker thread. The **DedicatedWorkerGlobalScope** class inherits from [WorkerGlobalScope](#workerglobalscope).
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p10704457184013"><a name="p10704457184013"></a><a name="p10704457184013"></a>Data to be sent to the worker.</p>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p8705857154016"><a name="p8705857154016"></a><a name="p8705857154016"></a><strong id="b39393445223"><a name="b39393445223"></a><a name="b39393445223"></a>ArrayBuffer</strong> instances that can be transferred. The <strong id="b161046012311"><a name="b161046012311"></a><a name="b161046012311"></a>transferList</strong> array cannot contain <strong id="b151041600231"><a name="b151041600231"></a><a name="b151041600231"></a>null</strong>.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
// main.js
import worker from "@ohos.worker";
const workerInstance = new worker.Worker("workers/worker.js")
workerInstance.postMessage("hello world")
workerInstance.onmessage = function(e) {
console.log("receive data from worker.js")
}
```
```
// worker.js
import worker from "@ohos.worker";
const parentPort = worker.parentPort;
parentPort.onmessage = function(e){
parentPort.postMessage("receive data from main.js")
}
```
### close<a name="section849610376427"></a>
close\(\): void
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| message | Object | Yes| Data to be sent to the worker.|
| options | [PostMessageOptions](#postmessageoptions) | No| **ArrayBuffer** instances that can be transferred. The **transferList** array cannot contain **null**.|
**Example**
```
// main.js
import worker from '@ohos.worker';
const workerInstance = new worker.Worker("workers/worker.js")
workerInstance.postMessage("hello world")
workerInstance.onmessage = function(e) {
console.log("receive data from worker.js")
}
```
```
// worker.js
import worker from '@ohos.worker';
const parentPort = worker.parentPort;
parentPort.onmessage = function(e){
parentPort.postMessage("receive data from main.js")
}
```
### close
close(): void
Closes the worker thread to stop the worker from receiving messages.
- Example
```
// main.js
import worker from '@ohos.worker';
const workerInstance = new worker.Worker("workers/worker.js")
```
```
// worker.js
import worker from "@ohos.worker";
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
parentPort.close()
}
```
### onmessage<a name="section1371121184815"></a>
onmessage?: \(event: MessageEvent\) =\> void
Defines the event handler to be called when the worker thread receives a message sent by the host thread through **worker.postMessage**. The event handler is executed in the worker thread.
const workerInstance = new worker.Worker("workers/worker.js")
```
```
// worker.js
import worker from '@ohos.worker';
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
parentPort.close()
}
```
### onmessage
onmessage?: (event: MessageEvent) => void
Defines the event handler to be called when the worker thread receives a message sent by the host thread through **worker.postMessage**. The event handler is executed in the worker thread.
const workerInstance = new worker.Worker("workers/worker.js")
workerInstance.postMessage("hello world")
```
```
// worker.js
import worker from '@ohos.worker';
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
console.log("receive main.js message")
}
```
### onmessageerror
onmessageerror?: (event: MessageEvent) => void
Defines the event handler to be called when the worker receives a message that cannot be deserialized. The event handler is executed in the worker thread.
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p18641139162415"><aname="p18641139162415"></a><aname="p18641139162415"></a><strongid="b29193411847"><aname="b29193411847"></a><aname="b29193411847"></a>ArrayBuffer</strong> array used to transfer the ownership.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p974715404504"><aname="p974715404504"></a><aname="p974715404504"></a>Type of the event.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p860554020511"><aname="p860554020511"></a><aname="p860554020511"></a>Timestamp (accurate to millisecond) when the event is created.</p>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p1178674203218"><a name="p1178674203218"></a><a name="p1178674203218"></a>Event class for the callback to invoke.</p>
<td class="cellrowborder" valign="top" width="78.16%" headers="mcps1.1.3.1.2 "><p id="a1c9b8d1829ef489e9e0fd1863190d228"><a name="a1c9b8d1829ef489e9e0fd1863190d228"></a><a name="a1c9b8d1829ef489e9e0fd1863190d228"></a>Returns no value or returns a <strong id="b33281532185513"><a name="b33281532185513"></a><a name="b33281532185513"></a>Promise</strong>.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
const workerInstance = new worker.Worker("workers/worker.js");
workerInstance.addEventListener("alert", (e)=>{
console.log("alert listener callback");
})
```
## ErrorEvent<a name="section11241623172418"></a>
Provides detailed information about the exception occurred during worker execution. The **ErrorEvent** class inherits from [Event](#section1674694018507).
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p92421123192418"><aname="p92421123192418"></a><aname="p92421123192418"></a>Information about the exception.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p524262320241"><aname="p524262320241"></a><aname="p524262320241"></a>File where the exception is located.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p23428465259"><aname="p23428465259"></a><aname="p23428465259"></a>Number of the line where the exception is located.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p1288319505259"><aname="p1288319505259"></a><aname="p1288319505259"></a>Number of the column where the exception is located.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p3175462267"><aname="p3175462267"></a><aname="p3175462267"></a>Type of the exception.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p612905514479"><aname="p612905514479"></a><aname="p612905514479"></a>Data transferred between threads.</p>
<tdclass="cellrowborder"valign="top"width="52.42%"headers="mcps1.1.6.1.5 "><pid="p196697562549"><aname="p196697562549"></a><aname="p196697562549"></a>Worker name specified when there is a new worker.</p>
>The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p19731837133019"><a name="p19731837133019"></a><a name="p19731837133019"></a><strong id="b176576351735"><a name="b176576351735"></a><a name="b176576351735"></a>ArrayBuffer</strong> or <strong id="b14983539439"><a name="b14983539439"></a><a name="b14983539439"></a>DataView</strong> for storing the XML information to write.</p>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p2406248191315"><a name="p2406248191315"></a><a name="p2406248191315"></a>Name of the empty element to add.</p>
</td>
</tr>
</tbody>
</table>
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the empty element to add.|
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p1564731811292"><a name="p1564731811292"></a><a name="p1564731811292"></a>Prefix of the element and its child elements.</p>
Creates and returns an **XmlPullParser** object. The **XmlPullParser** object passes two parameters. The first parameter is the memory of the **ArrayBuffer** or **DataView** type, and the second parameter is the file format \(UTF-8 by default\).
Creates and returns an **XmlPullParser** object. The **XmlPullParser** object passes two parameters. The first parameter is the memory of the **ArrayBuffer** or **DataView** type, and the second parameter is the file format (UTF-8 by default).
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| buffer | ArrayBuffer \| DataView | Yes| **ArrayBuffer** or **DataView** that contains XML text information.|
| encoding | string | No| Encoding format. Only UTF-8 is supported.|
**Example**
```
var strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var arrayBuffer = new ArrayBuffer(strXml.length*2);
var bufView = new Uint8Array(arrayBuffer);
var strLen = strXml.length;
for (var i = 0; i < strLen; ++i) {
bufView[i] = strXml.charCodeAt(i);// Set the ArrayBuffer mode.
<tdclass="cellrowborder"valign="top"width="36.18%"headers="mcps1.1.5.1.4 "><pid="p15609259215"><aname="p15609259215"></a><aname="p15609259215"></a>Whether to ignore <strongid="b1456884321714"><aname="b1456884321714"></a><aname="b1456884321714"></a>Doctype</strong>. The default value is <strongid="b1626514489171"><aname="b1626514489171"></a><aname="b1626514489171"></a>false</strong>.</p>
<tdclass="cellrowborder"valign="top"width="36.18%"headers="mcps1.1.5.1.4 "><pid="p1261012591114"><aname="p1261012591114"></a><aname="p1261012591114"></a>Whether to ignore <strongid="b649517181815"><aname="b649517181815"></a><aname="b649517181815"></a>Namespace</strong>. The default value is <strongid="b154747521819"><aname="b154747521819"></a><aname="b154747521819"></a>false</strong>.</p>
<tdclass="cellrowborder"valign="top"width="36.18%"headers="mcps1.1.5.1.4 "><pid="p1561095911110"><aname="p1561095911110"></a><aname="p1561095911110"></a>Callback used to return <strongid="b16819155133814"><aname="b16819155133814"></a><aname="b16819155133814"></a>tagValue</strong>.</p>
<tdclass="cellrowborder"valign="top"width="36.18%"headers="mcps1.1.5.1.4 "><pid="p1361010593112"><aname="p1361010593112"></a><aname="p1361010593112"></a>Callback used to return <strongid="b126354223386"><aname="b126354223386"></a><aname="b126354223386"></a>attributeValue</strong>.</p>
<tdclass="cellrowborder"valign="top"width="36.18%"headers="mcps1.1.5.1.4 "><pid="p156118592117"><aname="p156118592117"></a><aname="p156118592117"></a>Callback used to return <strongid="b1063617437387"><aname="b1063617437387"></a><aname="b1063617437387"></a>tokenValue</strong>.</p>
</td>
</tr>
</tbody>
</table>
## ParseInfo<a name="section436931815497"></a>
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| supportDoctype | boolean | No| Whether to ignore **Doctype**. The default value is **false**.|
| ignoreNameSpace | boolean | No| Whether to ignore **Namespace**. The default value is **false**.|
| tagValueCallbackFunction | (name: string, value: string)=> boolean | No| Callback used to return **tagValue**.|
| attributeValueCallbackFunction | (name: string, value: string)=> boolean | No| Callback used to return **attributeValue**.|
| tokenValueCallbackFunction | (eventType: [EventType](#eventtype), value: [ParseInfo](#parseinfo))=> boolean | No| Callback used to return **tokenValue**.|
## ParseInfo
Provides methods to manage the parsed XML information.
<tdclass="cellrowborder"valign="top"width="58.809999999999995%"headers="mcps1.1.4.1.3 "><pid="p820172175515"><aname="p820172175515"></a><aname="p820172175515"></a>Indicates an end document event.</p>
<tdclass="cellrowborder"valign="top"width="58.809999999999995%"headers="mcps1.1.4.1.3 "><pid="p27463438553"><aname="p27463438553"></a><aname="p27463438553"></a>Indicates a start tag event.</p>
<tdclass="cellrowborder"valign="top"width="58.809999999999995%"headers="mcps1.1.4.1.3 "><pid="p1279231415617"><aname="p1279231415617"></a><aname="p1279231415617"></a>Indicates an end tag event.</p>
<tdclass="cellrowborder"valign="top"width="58.809999999999995%"headers="mcps1.1.4.1.3 "><pid="p135559523569"><aname="p135559523569"></a><aname="p135559523569"></a>Indicates a text event.</p>
<tdclass="cellrowborder"valign="top"width="58.809999999999995%"headers="mcps1.1.4.1.3 "><pid="p11109135404716"><aname="p11109135404716"></a><aname="p11109135404716"></a>Indicates an XML comment event.</p>
<tdclass="cellrowborder"valign="top"width="58.809999999999995%"headers="mcps1.1.4.1.3 "><pid="p5109115444715"><aname="p5109115444715"></a><aname="p5109115444715"></a>Indicates an XML document type declaration event.</p>
<tdclass="cellrowborder"valign="top"width="58.809999999999995%"headers="mcps1.1.4.1.3 "><pid="p1685554515718"><aname="p1685554515718"></a><aname="p1685554515718"></a>Indicates an XML processing instruction event.</p>
<tdclass="cellrowborder"valign="top"width="58.809999999999995%"headers="mcps1.1.4.1.3 "><pid="p19990155145115"><aname="p19990155145115"></a><aname="p19990155145115"></a>Indicates a whitespace character event.</p>
</td>
</tr>
</tbody>
</table>
| Name| Value| Description|
| -------- | -------- | -------- |
| START_DOCUMENT | 0 | Indicates a start document event.|
| END_DOCUMENT | 1 | Indicates an end document event.|
| START_TAG | 2 | Indicates a start tag event.|
| END_TAG | 3 | Indicates an end tag event.|
| TEXT | 4 | Indicates a text event.|
| CDSECT | 5 | Indicates a CDATA section event.|
| COMMENT | 6 | Indicates an XML comment event.|
| DOCDECL | 7 | Indicates an XML document type declaration event.|
| INSTRUCTION | 8 | Indicates an XML processing instruction event.|
| ENTITY_REFERENCE | 9 | Indicates an entity reference event.|
| WHITESPACE | 10 | Indicates a whitespace character event.|