@structium/xml - API documentation β
Functions β
deserialize() β
ts
function deserialize<Res>(input: string, options?: DeserializeOptions): Promise<Res>Parses an XML content string into a JavaScript object.
Type Parameters β
| Type Parameter | Default type | Description |
|---|---|---|
Res extends CommonObj | CommonObj | The expected return type of the parsed object. |
Parameters β
| Parameter | Type | Description |
|---|---|---|
input | string | The XML content string to be parsed. |
options? | DeserializeOptions | Options to pass to the XML parser. |
Returns β
Promise<Res>
- A promise that resolves to the parsed XML as an object.
Throws β
If there is an error parsing the XML content.
serialize() β
ts
function serialize<I>(input: I): Promise<string>Converts a JavaScript object into an XML string.
Type Parameters β
| Type Parameter | Default type | Description |
|---|---|---|
I extends CommonObj | CommonObj | The type of the object to be converted. |
Parameters β
| Parameter | Type | Description |
|---|---|---|
input | I | The object to be converted. |
Returns β
Promise<string>
- A promise that resolves to the XML string.
