提交 02115071 编写于 作者: W wusongqing

update docs against 5767

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 76c75b09
# URL String Parsing # URL String Parsing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
>
> 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.
...@@ -10,10 +11,6 @@ ...@@ -10,10 +11,6 @@
import Url from '@ohos.url' import Url from '@ohos.url'
``` ```
## System Capabilities
SystemCapability.Utils.Lang
## URLSearchParams ## URLSearchParams
...@@ -23,20 +20,22 @@ constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLSearc ...@@ -23,20 +20,22 @@ constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLSearc
Creates a **URLSearchParams** instance. Creates a **URLSearchParams** instance.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| init | string[][]&nbsp;\|&nbsp;Record&lt;string,&nbsp;string&gt;&nbsp;\|&nbsp;string&nbsp;\|&nbsp;URLSearchParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>- **Record&lt;string,&nbsp;string&gt;**: list of objects<br>- **string**: string<br>- **URLSearchParams**: object| | init | string[][] \| Record&lt;string, string&gt; \| string \| URLSearchParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>- **Record&lt;string, string&gt;**: list of objects<br>- **string**: string<br>- **URLSearchParams**: object |
**Example** **Example**
```js ```js
var objectParams = new URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]); var objectParams = new Url.URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]);
var objectParams1 = new URLSearchParams({"fod" : 1 , "bard" : 2}); var objectParams1 = new Url.URLSearchParams({"fod" : 1 , "bard" : 2});
var objectParams2 = new URLSearchParams('?fod=1&bard=2'); var objectParams2 = new Url.URLSearchParams('?fod=1&bard=2');
var urlObject = new URL('https://developer.mozilla.org/?fod=1&bard=2'); var urlObject = new Url.URL('https://developer.mozilla.org/?fod=1&bard=2');
var params = new URLSearchParams(urlObject.search); var params = new Url.URLSearchParams(urlObject.search);
``` ```
...@@ -46,18 +45,20 @@ append(name: string, value: string): void ...@@ -46,18 +45,20 @@ append(name: string, value: string): void
Appends a key-value pair into the query string. Appends a key-value pair into the query string.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Key of the key-value pair to append.| | name | string | Yes | Key of the key-value pair to append. |
| value | string | Yes| Value of the key-value pair to append.| | value | string | Yes | Value of the key-value pair to append. |
**Example** **Example**
```js ```js
let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new URLSearchParams(urlObject.search.slice(1)); let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1));
paramsObject.append('fod', 3); paramsObject.append('fod', 3);
``` ```
...@@ -68,17 +69,19 @@ delete(name: string): void ...@@ -68,17 +69,19 @@ delete(name: string): void
Deletes key-value pairs of the specified key. Deletes key-value pairs of the specified key.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Key of the key-value pairs to delete.| | name | string | Yes | Key of the key-value pairs to delete. |
**Example** **Example**
```js ```js
let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsobject = new URLSearchParams(urlObject.search.slice(1)); let paramsobject = new Url.URLSearchParams(urlObject.search.slice(1));
paramsobject.delete('fod'); paramsobject.delete('fod');
``` ```
...@@ -89,23 +92,25 @@ getAll(name: string): string[] ...@@ -89,23 +92,25 @@ getAll(name: string): string[]
Obtains all the key-value pairs based on the specified key. Obtains all the key-value pairs based on the specified key.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to obtain all key-value pairs.| | name | string | Yes | Key specified to obtain all key-value pairs. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| string[] | All key-value pairs matching the specified key.| | string[] | All key-value pairs matching the specified key. |
**Example** **Example**
```js ```js
let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new URLSearchParams(urlObject.search.slice(1)); let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1));
paramsObject.append('fod', 3); // Add a second value for the fod parameter. paramsObject.append('fod', 3); // Add a second value for the fod parameter.
console.log(params.getAll('fod')) // Output ["1","3"]. console.log(params.getAll('fod')) // Output ["1","3"].
``` ```
...@@ -117,16 +122,18 @@ entries(): IterableIterator<[string, string]> ...@@ -117,16 +122,18 @@ entries(): IterableIterator<[string, string]>
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. 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.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| IterableIterator&lt;[string,&nbsp;string]&gt; | ES6 iterator.| | IterableIterator&lt;[string, string]&gt; | ES6 iterator. |
**Example** **Example**
```js ```js
var searchParamsObject = new URLSearchParams("keyName1=valueName1&keyName2=valueName2"); var searchParamsObject = new Url.URLSearchParams("keyName1=valueName1&keyName2=valueName2");
for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs
console.log(pair[0]+ ', '+ pair[1]); console.log(pair[0]+ ', '+ pair[1]);
} }
...@@ -139,25 +146,27 @@ forEach(callbackfn: (value: string, key: string, searchParams: this) => void, th ...@@ -139,25 +146,27 @@ forEach(callbackfn: (value: string, key: string, searchParams: this) => void, th
Traverses the key-value pairs in the **URLSearchParams** instance by using a callback. Traverses the key-value pairs in the **URLSearchParams** instance by using a callback.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackfn | function | Yes| Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance.| | callbackfn | function | Yes | Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance. |
| thisArg | Object | No| Value to use when the callback is invoked.| | thisArg | Object | No | Value to use when the callback is invoked. |
**Table 1** callbackfn parameter description **Table 1** callbackfn parameter description
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | string | Yes| Value that is currently traversed.| | value | string | Yes | Value that is currently traversed. |
| key | string | Yes| Key that is currently traversed.| | key | string | Yes | Key that is currently traversed. |
| searchParams | Object | Yes| Instance that invokes the **forEach** method.| | searchParams | Object | Yes | Instance that invokes the **forEach** method. |
**Example** **Example**
```js ```js
const myURLObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); const myURLObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
myURLObject.searchParams.forEach((value, name, searchParams) => { myURLObject.searchParams.forEach((value, name, searchParams) => {
console.log(name, value, myURLObject.searchParams === searchParams); console.log(name, value, myURLObject.searchParams === searchParams);
}); });
...@@ -170,23 +179,25 @@ get(name: string): string | null ...@@ -170,23 +179,25 @@ get(name: string): string | null
Obtains the value of the first key-value pair based on the specified key. Obtains the value of the first key-value pair based on the specified key.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to obtain the value.| | name | string | Yes | Key specified to obtain the value. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| string | Returns the value of the first key-value pair if obtained.| | string | Returns the value of the first key-value pair if obtained. |
| null | Returns null if no value is obtained.| | null | Returns null if no value is obtained. |
**Example** **Example**
```js ```js
var paramsOject = new URLSearchParams(document.location.search.substring(1)); var paramsOject = new Url.URLSearchParams(document.location.search.substring(1));
var name = paramsOject.get("name"); // is the string "Jonathan" var name = paramsOject.get("name"); // is the string "Jonathan"
var age = parseInt(paramsOject.get("age"), 10); // is the number 18 var age = parseInt(paramsOject.get("age"), 10); // is the number 18
var address = paramsOject.get("address"); // null var address = paramsOject.get("address"); // null
...@@ -199,23 +210,25 @@ has(name: string): boolean ...@@ -199,23 +210,25 @@ has(name: string): boolean
Checks whether a key has a value. Checks whether a key has a value.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Key specified to search for its value.| | name | string | Yes | Key specified to search for its value. |
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the value exists; returns **false** otherwise.| | boolean | Returns **true** if the value exists; returns **false** otherwise. |
**Example** **Example**
```js ```js
let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new URLSearchParams(urlObject.search.slice(1)); let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1));
paramsObject.has('bard') === true; paramsObject.has('bard') === true;
``` ```
...@@ -226,18 +239,20 @@ set(name: string, value: string): void ...@@ -226,18 +239,20 @@ set(name: string, value: string): void
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. 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.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Key of the value to set.| | name | string | Yes | Key of the value to set. |
| value | string | Yes| Value to set.| | value | string | Yes | Value to set. |
**Example** **Example**
```js ```js
let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new URLSearchParams(urlObject.search.slice(1)); let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1));
paramsObject.set('baz', 3); // Add a third parameter. paramsObject.set('baz', 3); // Add a third parameter.
``` ```
...@@ -246,13 +261,14 @@ paramsObject.set('baz', 3); // Add a third parameter. ...@@ -246,13 +261,14 @@ paramsObject.set('baz', 3); // Add a third parameter.
sort(): void 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.
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. **System capability**: SystemCapability.Utils.Lang
**Example** **Example**
```js ```js
var searchParamsObject = new URLSearchParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object var searchParamsObject = new Url.URLSearchParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object
searchParamsObject.sort(); // Sort the key/value pairs 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 console.log(searchParamsObject.toString()); // Display the sorted query string // Output a=9&b=2&c=3&d=4
``` ```
...@@ -262,19 +278,20 @@ console.log(searchParamsObject.toString()); // Display the sorted query string / ...@@ -262,19 +278,20 @@ console.log(searchParamsObject.toString()); // Display the sorted query string /
keys(): IterableIterator&lt;string&gt; keys(): IterableIterator&lt;string&gt;
Obtains an ES6 iterator that contains the keys of all the key-value pairs. Obtains an ES6 iterator that contains the keys of all the key-value pairs.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| IterableIterator&lt;string&gt; | ES6 iterator that contains the keys of all the key-value pairs.| | IterableIterator&lt;string&gt; | ES6 iterator that contains the keys of all the key-value pairs. |
**Example** **Example**
```js ```js
var searchParamsObject = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing var searchParamsObject = new Url.URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing
for (var key of searchParamsObject .keys()) { // Output key-value pairs for (var key of searchParamsObject .keys()) { // Output key-value pairs
console.log(key); console.log(key);
} }
...@@ -287,16 +304,18 @@ values(): IterableIterator&lt;string&gt; ...@@ -287,16 +304,18 @@ values(): IterableIterator&lt;string&gt;
Obtains an ES6 iterator that contains the values of all the key-value pairs. Obtains an ES6 iterator that contains the values of all the key-value pairs.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| IterableIterator&lt;string&gt; | ES6 iterator that contains the values of all the key-value pairs.| | IterableIterator&lt;string&gt; | ES6 iterator that contains the values of all the key-value pairs. |
**Example** **Example**
```js ```js
var searchParams = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing var searchParams = new Url.URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing
for (var value of searchParams.values()) { for (var value of searchParams.values()) {
console.log(value); console.log(value);
} }
...@@ -307,19 +326,20 @@ for (var value of searchParams.values()) { ...@@ -307,19 +326,20 @@ for (var value of searchParams.values()) {
[Symbol.iterator]\(): IterableIterator&lt;[string, string]&gt; [Symbol.iterator]\(): IterableIterator&lt;[string, string]&gt;
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. 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.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| IterableIterator&lt;[string,&nbsp;string]&gt; | ES6 iterator.| | IterableIterator&lt;[string, string]&gt; | ES6 iterator. |
**Example** **Example**
```js ```js
const paramsObject = new URLSearchParams('fod=bay&edg=bap'); const paramsObject = new Url.URLSearchParams('fod=bay&edg=bap');
for (const [name, value] of paramsObject) { for (const [name, value] of paramsObject) {
console.log(name, value); console.log(name, value);
} }
...@@ -330,20 +350,21 @@ for (const [name, value] of paramsObject) { ...@@ -330,20 +350,21 @@ for (const [name, value] of paramsObject) {
toString(): string toString(): string
Obtains search parameters that are serialized as a string and, if necessary, percent-encodes the characters in the string. Obtains search parameters that are serialized as a string and, if necessary, percent-encodes the characters in the string.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| string | String of serialized search parameters, which is percent-encoded if necessary.| | string | String of serialized search parameters, which is percent-encoded if necessary. |
**Example** **Example**
```js ```js
let url = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let url = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2');
let params = new URLSearchParams(url.search.slice(1)); let params = new Url.URLSearchParams(url.search.slice(1));
params.append('fod', 3); params.append('fod', 3);
console.log(params.toString()); console.log(params.toString());
``` ```
...@@ -351,9 +372,10 @@ console.log(params.toString()); ...@@ -351,9 +372,10 @@ console.log(params.toString());
## URL ## URL
### Attributes ### Attributes
**System capability**: SystemCapability.Utils.Lang
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| hash | string | Yes| Yes| String that contains a harsh mark (#) followed by the fragment identifier of a URL.| | hash | string | Yes| Yes| String that contains a harsh mark (#) followed by the fragment identifier of a URL.|
...@@ -374,31 +396,32 @@ console.log(params.toString()); ...@@ -374,31 +396,32 @@ console.log(params.toString());
constructor(url: string, base?: string | URL) constructor(url: string, base?: string | URL)
Creates a URL. Creates a URL.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| url | string | Yes| Input object.| | url | string | Yes | Input object. |
| base | string&nbsp;\|&nbsp;URL | No| Input parameter, which can be any of the following:<br>- **string**: string<br>- **URL**: string or object| | base | string \ |& URL | No | Input parameter, which can be any of the following:<br>- **string**: string<br>- **URL**: string or object |
**Example** **Example**
```js ```js
var mm = 'http://username:password@host:8080'; var mm = 'http://username:password@host:8080';
var a = new URL("/", mm); // Output 'http://username:password@host:8080/'; var a = new Url.URL("/", mm); // Output 'http://username:password@host:8080/';
var b = new URL(mm); // Output 'http://username:password@host:8080/'; var b = new Url.URL(mm); // Output 'http://username:password@host:8080/';
new URL('path/path1', b); // Output 'http://username:password@host:8080/path/path1'; new Url.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'; var c = new Url.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.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.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.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.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.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.URL('http://www.shanxi.com', ); // Output http://www.shanxi.com/
new URL('http://www.shanxi.com', b); // Output http://www.shanxi.com/ new Url.URL('http://www.shanxi.com', b); // Output http://www.shanxi.com/
``` ```
...@@ -408,16 +431,18 @@ toString(): string ...@@ -408,16 +431,18 @@ toString(): string
Converts the parsed URL into a string. Converts the parsed URL into a string.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| string | Website address in a serialized string.| | string | Website address in a serialized string. |
**Example** **Example**
```js ```js
const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toString() url.toString()
``` ```
...@@ -426,17 +451,18 @@ url.toString() ...@@ -426,17 +451,18 @@ url.toString()
toJSON(): string toJSON(): string
Converts the parsed URL into a JSON string. Converts the parsed URL into a JSON string.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | -------- | -------- |
| string | Website address in a serialized string.| | string | Website address in a serialized string. |
**Example** **Example**
```js ```js
const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toJSON() url.toJSON()
``` ```
\ No newline at end of file
# util # util
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
>
> 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.
This module provides common utility functions, such as **TextEncoder** and **TextDecoder** for string encoding and decoding, **RationalNumber** for rational number operations, **LruBuffer** for buffer management, **Scope** for range determination, **Base64** for Base64 encoding and decoding, and **types** for checks of built-in object types. This module provides common utility functions, such as **TextEncoder** and **TextDecoder** for string encoding and decoding, **RationalNumber** for rational number operations, **LruBuffer** for buffer management, **Scope** for range determination, **Base64** for Base64 encoding and decoding, and **Types** for checks of built-in object types.
## Modules to Import ## Modules to Import
...@@ -140,7 +141,7 @@ Processes an asynchronous function and returns a promise version. ...@@ -140,7 +141,7 @@ Processes an asynchronous function and returns a promise version.
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| encoding | string | Yes| No| Encoding format.<br>-&nbsp;Supported formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac-cyrilli, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, euc-kr, utf-16be, utf-16le| | encoding | string | Yes| No| Encoding format.<br>- Supported formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac-cyrilli, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, euc-kr, utf-16be, utf-16le|
| fatal | boolean | Yes| No| Whether to display fatal errors.| | fatal | boolean | Yes| No| Whether to display fatal errors.|
| ignoreBOM | boolean | Yes| No| Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM.| | ignoreBOM | boolean | Yes| No| Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM.|
...@@ -208,9 +209,6 @@ Decodes the input content. ...@@ -208,9 +209,6 @@ Decodes the input content.
result[4] = 0x62; result[4] = 0x62;
result[5] = 0x63; result[5] = 0x63;
console.log("input num:"); console.log("input num:");
for(var j= 0; j < 6; j++) {
console.log(result[j]);
}
var retStr = textDecoder.decode( result , {stream: false}); var retStr = textDecoder.decode( result , {stream: false});
console.log("retStr = " + retStr); console.log("retStr = " + retStr);
``` ```
...@@ -262,6 +260,7 @@ Encodes the input content. ...@@ -262,6 +260,7 @@ Encodes the input content.
**Example** **Example**
```js ```js
var textEncoder = new util.TextEncoder(); var textEncoder = new util.TextEncoder();
var buffer = new ArrayBuffer(20);
var result = new Uint8Array(buffer); var result = new Uint8Array(buffer);
result = textEncoder.encode("\uD800¥¥"); result = textEncoder.encode("\uD800¥¥");
``` ```
...@@ -361,7 +360,6 @@ Compares this **RationalNumber** object with a given object. ...@@ -361,7 +360,6 @@ Compares this **RationalNumber** object with a given object.
| number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object.| | number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object.|
**Example** **Example**
```js ```js
var rationalNumber = new util.RationalNumber(1,2); var rationalNumber = new util.RationalNumber(1,2);
var rational = rationalNumer.creatRationalFromString("3/4"); var rational = rationalNumer.creatRationalFromString("3/4");
...@@ -484,7 +482,7 @@ Obtains the denominator of this **RationalNumber** object. ...@@ -484,7 +482,7 @@ Obtains the denominator of this **RationalNumber** object.
### isZero<sup>8+</sup> ### isZero<sup>8+</sup>
isZero​(): boolean isZero​():boolean
Checks whether this **RationalNumber** object is **0**. Checks whether this **RationalNumber** object is **0**.
...@@ -524,7 +522,7 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN). ...@@ -524,7 +522,7 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN).
### isFinite<sup>8+</sup> ### isFinite<sup>8+</sup>
isFinite​(): boolean isFinite​():boolean
Checks whether this **RationalNumber** object represents a finite value. Checks whether this **RationalNumber** object represents a finite value.
...@@ -825,7 +823,7 @@ Obtains the value of the specified key. ...@@ -825,7 +823,7 @@ Obtains the value of the specified key.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| V&nbsp;\|&nbsp;undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.| | V \| undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.|
**Example** **Example**
```js ```js
...@@ -872,7 +870,7 @@ Obtains all values in this buffer, listed from the most to the least recently ac ...@@ -872,7 +870,7 @@ Obtains all values in this buffer, listed from the most to the least recently ac
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| V&nbsp;[] | All values in the buffer, listed from the most to the least recently accessed.| | V [] | All values in the buffer, listed from the most to the least recently accessed.|
**Example** **Example**
```js ```js
...@@ -895,7 +893,7 @@ Obtains all keys in this buffer, listed from the most to the least recently acce ...@@ -895,7 +893,7 @@ Obtains all keys in this buffer, listed from the most to the least recently acce
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| K&nbsp;[] | All keys in the buffer, listed from the most to the least recently accessed.| | K [] | All keys in the buffer, listed from the most to the least recently accessed.|
**Example** **Example**
```js ```js
...@@ -921,7 +919,7 @@ Removes the specified key and its value from this buffer. ...@@ -921,7 +919,7 @@ Removes the specified key and its value from this buffer.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| V&nbsp;\|&nbsp;undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.| | V \| undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.|
**Example** **Example**
```js ```js
...@@ -1038,7 +1036,7 @@ Obtains a new iterator object that contains all key-value pairs in this object. ...@@ -1038,7 +1036,7 @@ Obtains a new iterator object that contains all key-value pairs in this object.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [K,&nbsp;V] | Iterable array.| | [K, V] | Iterable array.|
**Example** **Example**
```js ```js
...@@ -1059,7 +1057,7 @@ Obtains a two-dimensional array in key-value pairs. ...@@ -1059,7 +1057,7 @@ Obtains a two-dimensional array in key-value pairs.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [K,&nbsp;V] | Two-dimensional array in key-value pairs.| | [K, V] | Two-dimensional array in key-value pairs.|
**Example** **Example**
```js ```js
...@@ -1092,6 +1090,8 @@ Example ...@@ -1092,6 +1090,8 @@ Example
```js ```js
class Temperature{ class Temperature{
constructor(value){ constructor(value){
// If TS is used for development, add the following code:
// private readonly _temp: Temperature;
this._temp = value; this._temp = value;
} }
comapreTo(value){ comapreTo(value){
...@@ -1183,7 +1183,7 @@ Obtains the intersection of this **Scope** and the given **Scope**. ...@@ -1183,7 +1183,7 @@ Obtains the intersection of this **Scope** and the given **Scope**.
### intersect<sup>8+</sup> ### intersect<sup>8+</sup>
intersect(lowerObj: ScopeType,upperObj: ScopeType): Scope intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope
Obtains the intersection of this **Scope** and the given lower and upper limits. Obtains the intersection of this **Scope** and the given lower and upper limits.
...@@ -1276,6 +1276,7 @@ Obtains the union set of this **Scope** and the given lower and upper limits. ...@@ -1276,6 +1276,7 @@ Obtains the union set of this **Scope** and the given lower and upper limits.
| [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.| | [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.|
**Example** **Example**
```js ```js
var tempLower = new Temperature(30); var tempLower = new Temperature(30);
var tempUpper = new Temperature(40); var tempUpper = new Temperature(40);
...@@ -1288,7 +1289,7 @@ Obtains the union set of this **Scope** and the given lower and upper limits. ...@@ -1288,7 +1289,7 @@ Obtains the union set of this **Scope** and the given lower and upper limits.
### expand<sup>8+</sup> ### expand<sup>8+</sup>
expand(range:Scope):Scope expand(range: Scope): Scope
Obtains the union set of this **Scope** and the given **Scope**. Obtains the union set of this **Scope** and the given **Scope**.
...@@ -1510,7 +1511,7 @@ Decodes the input content. ...@@ -1510,7 +1511,7 @@ Decodes the input content.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array&nbsp;\|&nbsp;string | Yes| Uint8Array or string to decode.| | src | Uint8Array \| string | Yes| Uint8Array or string to decode.|
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -1595,7 +1596,7 @@ Decodes the input content asynchronously. ...@@ -1595,7 +1596,7 @@ Decodes the input content asynchronously.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| src | Uint8Array&nbsp;\|&nbsp;string | Yes| Uint8Array or string to decode asynchronously.| | src | Uint8Array \| string | Yes| Uint8Array or string to decode asynchronously.|
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -1622,7 +1623,7 @@ Decodes the input content asynchronously. ...@@ -1622,7 +1623,7 @@ Decodes the input content asynchronously.
constructor() constructor()
A constructor used to create a **types** object. A constructor used to create a **Types** object.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
......
# XML Parsing and Generation # XML Parsing and Generation
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **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. > 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.
...@@ -10,10 +11,6 @@ ...@@ -10,10 +11,6 @@
import xml from '@ohos.xml'; import xml from '@ohos.xml';
``` ```
## System Capabilities
SystemCapability.Utils.Lang
## XmlSerializer ## XmlSerializer
...@@ -23,11 +20,13 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string) ...@@ -23,11 +20,13 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string)
A constructor used to create an **XmlSerializer** instance. A constructor used to create an **XmlSerializer** instance.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| buffer | ArrayBuffer&nbsp;\|&nbsp;DataView | Yes| **ArrayBuffer** or **DataView** for storing the XML information to write.| | buffer | ArrayBuffer \| DataView | Yes| **ArrayBuffer** or **DataView** for storing the XML information to write.|
| encoding | string | No| Encoding format.| | encoding | string | No| Encoding format.|
**Example** **Example**
...@@ -45,6 +44,8 @@ setAttributes(name: string, value: string): void ...@@ -45,6 +44,8 @@ setAttributes(name: string, value: string): void
Sets an attribute. Sets an attribute.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -55,6 +56,8 @@ Sets an attribute. ...@@ -55,6 +56,8 @@ Sets an attribute.
**Example** **Example**
```js ```js
var arrayBuffer = new ArrayBuffer(1024);
var bufView = new DataView(arrayBuffer);
var thatSer = new xml.XmlSerializer(bufView); var thatSer = new xml.XmlSerializer(bufView);
thatSer.setAttributes("importance", "high"); thatSer.setAttributes("importance", "high");
``` ```
...@@ -66,6 +69,8 @@ addEmptyElement(name: string): void ...@@ -66,6 +69,8 @@ addEmptyElement(name: string): void
Adds an empty element. Adds an empty element.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -75,6 +80,8 @@ Adds an empty element. ...@@ -75,6 +80,8 @@ Adds an empty element.
**Example** **Example**
```js ```js
var arrayBuffer = new ArrayBuffer(1024);
var bufView = new DataView(arrayBuffer);
var thatSer = new xml.XmlSerializer(bufView); var thatSer = new xml.XmlSerializer(bufView);
thatSer.addEmptyElement("b"); // => <b/> thatSer.addEmptyElement("b"); // => <b/>
``` ```
...@@ -86,9 +93,13 @@ setDeclaration(): void ...@@ -86,9 +93,13 @@ setDeclaration(): void
Sets a declaration. Sets a declaration.
**System capability**: SystemCapability.Utils.Lang
**Example** **Example**
```js ```js
var arrayBuffer = new ArrayBuffer(1024);
var bufView = new DataView(arrayBuffer);
var thatSer = new xml.XmlSerializer(bufView); var thatSer = new xml.XmlSerializer(bufView);
thatSer.setDeclaration() // => <?xml version="1.0" encoding="utf-8"?>; thatSer.setDeclaration() // => <?xml version="1.0" encoding="utf-8"?>;
``` ```
...@@ -100,6 +111,8 @@ startElement(name: string): void ...@@ -100,6 +111,8 @@ startElement(name: string): void
Writes the start tag based on the given element name. Writes the start tag based on the given element name.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -122,9 +135,13 @@ endElement(): void ...@@ -122,9 +135,13 @@ endElement(): void
Writes the end tag of the element. Writes the end tag of the element.
**System capability**: SystemCapability.Utils.Lang
**Example** **Example**
```js ```js
var arrayBuffer = new ArrayBuffer(1024);
var bufView = new DataView(arrayBuffer);
var thatSer = new xml.XmlSerializer(bufView); var thatSer = new xml.XmlSerializer(bufView);
thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
thatSer.startElement("table"); thatSer.startElement("table");
...@@ -140,6 +157,8 @@ setNamespace(prefix: string, namespace: string): void ...@@ -140,6 +157,8 @@ setNamespace(prefix: string, namespace: string): void
Sets the namespace for an element tag. Sets the namespace for an element tag.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -164,6 +183,8 @@ setComment(text: string): void ...@@ -164,6 +183,8 @@ setComment(text: string): void
Sets the comment. Sets the comment.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -187,6 +208,8 @@ setCDATA(text: string): void ...@@ -187,6 +208,8 @@ setCDATA(text: string): void
Sets CDATA attributes. Sets CDATA attributes.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -208,6 +231,8 @@ setText(text: string): void ...@@ -208,6 +231,8 @@ setText(text: string): void
Sets **Text**. Sets **Text**.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -232,6 +257,8 @@ setDocType(text: string): void ...@@ -232,6 +257,8 @@ setDocType(text: string): void
Sets **DocType**. Sets **DocType**.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -256,11 +283,13 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string) ...@@ -256,11 +283,13 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string)
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).
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| buffer | ArrayBuffer&nbsp;\|&nbsp;DataView | Yes| **ArrayBuffer** or **DataView** that contains XML text information.| | buffer | ArrayBuffer \| DataView | Yes| **ArrayBuffer** or **DataView** that contains XML text information.|
| encoding | string | No| Encoding format. Only UTF-8 is supported.| | encoding | string | No| Encoding format. Only UTF-8 is supported.|
**Example** **Example**
...@@ -289,6 +318,8 @@ parse(option: ParseOptions): void ...@@ -289,6 +318,8 @@ parse(option: ParseOptions): void
Parses XML information. Parses XML information.
**System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -329,14 +360,16 @@ that.parse(options); ...@@ -329,14 +360,16 @@ that.parse(options);
Defines the XML parsing options. Defines the XML parsing options.
**System capability**: SystemCapability.Utils.Lang
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| supportDoctype | boolean | No| Whether to ignore **Doctype**. The default value is **false**.| | supportDoctype | boolean | No| Whether to ignore **Doctype**. The default value is **false**.|
| ignoreNameSpace | boolean | No| Whether to ignore **Namespace**. The default value is **false**.| | ignoreNameSpace | boolean | No| Whether to ignore **Namespace**. The default value is **false**.|
| tagValueCallbackFunction | (name:&nbsp;string,&nbsp;value:&nbsp;string)=&gt;&nbsp;boolean | No| Callback used to return **tagValue**.| | tagValueCallbackFunction | (name: string, value: string)=&gt; boolean | No| Callback used to return **tagValue**.|
| attributeValueCallbackFunction | (name:&nbsp;string,&nbsp;value:&nbsp;string)=&gt;&nbsp;boolean | No| Callback used to return **attributeValue**.| | attributeValueCallbackFunction | (name: string, value: string)=&gt; boolean | No| Callback used to return **attributeValue**.|
| tokenValueCallbackFunction | (eventType:&nbsp;[EventType](#eventtype),&nbsp;value:&nbsp;[ParseInfo](#parseinfo))=&gt;&nbsp;boolean | No| Callback used to return **tokenValue**.| | tokenValueCallbackFunction | (eventType: [EventType](#eventtype), value: [ParseInfo](#parseinfo))=&gt; boolean | No| Callback used to return **tokenValue**.|
## ParseInfo ## ParseInfo
...@@ -349,6 +382,8 @@ getColumnNumber(): number ...@@ -349,6 +382,8 @@ getColumnNumber(): number
Obtains the column line number, which starts from 1. Obtains the column line number, which starts from 1.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -362,6 +397,8 @@ getDepth(): number ...@@ -362,6 +397,8 @@ getDepth(): number
Obtains the depth of this element. Obtains the depth of this element.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -375,6 +412,8 @@ getLineNumber(): number ...@@ -375,6 +412,8 @@ getLineNumber(): number
Obtains the current line number, starting from 1. Obtains the current line number, starting from 1.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -388,6 +427,8 @@ getName(): string ...@@ -388,6 +427,8 @@ getName(): string
Obtains the name of this element. Obtains the name of this element.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -401,6 +442,8 @@ getNamespace(): string ...@@ -401,6 +442,8 @@ getNamespace(): string
Obtains the namespace of this element. Obtains the namespace of this element.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -414,6 +457,8 @@ getPrefix(): string ...@@ -414,6 +457,8 @@ getPrefix(): string
Obtains the prefix of this element. Obtains the prefix of this element.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -427,6 +472,8 @@ getText(): string ...@@ -427,6 +472,8 @@ getText(): string
Obtains the text of the current event. Obtains the text of the current event.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -440,6 +487,8 @@ isEmptyElementTag(): boolean ...@@ -440,6 +487,8 @@ isEmptyElementTag(): boolean
Checks whether the current element is empty. Checks whether the current element is empty.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -453,6 +502,8 @@ isWhitespace(): boolean ...@@ -453,6 +502,8 @@ isWhitespace(): boolean
Checks whether the current text event contains only whitespace characters. Checks whether the current text event contains only whitespace characters.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -466,6 +517,8 @@ getAttributeCount(): number ...@@ -466,6 +517,8 @@ getAttributeCount(): number
Obtains the number of attributes for the current start tag. Obtains the number of attributes for the current start tag.
**System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
...@@ -476,6 +529,8 @@ Obtains the number of attributes for the current start tag. ...@@ -476,6 +529,8 @@ Obtains the number of attributes for the current start tag.
Enumerates the events. Enumerates the events.
**System capability**: SystemCapability.Utils.Lang
| Name| Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| START_DOCUMENT | 0 | Indicates a start document event.| | START_DOCUMENT | 0 | Indicates a start document event.|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册