Skip to content

ConvertTo XmlElements

github-actions edited this page Jun 3, 2026 · 1 revision

external help file: XMLLab-help.xml Module Name: XMLLab online version: schema: 2.0.0

ConvertTo-XmlElements

SYNOPSIS

Serializes complex content into XML elements.

SYNTAX

ConvertTo-XmlElements [[-InputObject] <Object>] [-Depth <Int32>] [-SkipRoot]
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

{{ Fill in the Description }}

EXAMPLES

EXAMPLE 1

ConvertTo-XmlElements @{html=@{body=@{p='Some text.'}}} -SkipRoot

<html> <body> <p>Some text.</p> </body> </html>

EXAMPLE 2

[pscustomobject]@{UserName='zaphodb';Computer='eddie'} |ConvertTo-XmlElements

<PSCustomObject> <UserName>zaphodb</UserName> <Computer>eddie</Computer> </PSCustomObject>

EXAMPLE 3

'{"item": {"name": "Test", "id": 1 } }' |ConvertFrom-Json |ConvertTo-XmlElements -SkipRoot

<item> <name>Test</name> <id>1</id> </item>

PARAMETERS

-InputObject

A hash or XML element or other object to be serialized as XML elements.

Each hash value or object property value may itself be a hash or object or XML element.

Type: Object
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Depth

Specifies how many levels of contained objects are included in the JSON representation. The value can be any number from 0 to 100. The default value is 2. ConvertTo-Json emits a warning if the number of levels in an input object exceeds this number.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: 3
Accept pipeline input: False
Accept wildcard characters: False

-SkipRoot

Do not wrap the input in a root element.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.Object (any object) to serialize.

OUTPUTS

System.String for each XML-serialized value or property.

NOTES

RELATED LINKS

Clone this wiki locally