Skip to content

Format Xml

Apostolis Bekiaris edited this page Oct 7, 2019 · 1 revision

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

Format-Xml

SYNOPSIS

Pretty-print formatted XML source

SYNTAX

Document

Format-Xml [-Xml] <Object> [-Indent <Int32>] [-Character <Char>] [<CommonParameters>]

File

Format-Xml [-Path] <String> [-Indent <Int32>] [-Character <Char>] [<CommonParameters>]

DESCRIPTION

Runs an XmlDocument through an auto-indenting XmlWriter

EXAMPLES

EXAMPLE 1

[xml]$xml = get-content Data.xml

C:\PS>Format-Xml $xml

EXAMPLE 2

get-content Data.xml | Format-Xml

EXAMPLE 3

Format-Xml C:\PS\Data.xml -indent 1 -char `t

Shows how to convert the indentation to tabs (which can save bytes dramatically, while preserving readability)

EXAMPLE 4

ls *.xml | Format-Xml

PARAMETERS

-Xml

The Xml Document

Type: Object
Parameter Sets: Document
Aliases:

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

-Path

The path to an xml document (on disc or any other content provider).

Type: String
Parameter Sets: File
Aliases: PsPath

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

-Indent

The indent level (defaults to 2 spaces)

Type: Int32
Parameter Sets: (All)
Aliases:

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

-Character

The indent character (defaults to a space)

Type: Char
Parameter Sets: (All)
Aliases:

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

OUTPUTS

NOTES

RELATED LINKS

Star the project if you think it deserves it.

GitHub stars

Fork the project to extend and contribute.

GitHub forks

Clone this wiki locally
You can’t perform that action at this time.