-
-
Notifications
You must be signed in to change notification settings - Fork 7
Format Xml
apobekiaris edited this page Sep 4, 2020
·
5 revisions
Pretty-print formatted XML source
Format-Xml [-Xml] <XmlDocument> [-Indent <Int32>] [-Character <Char>] [<CommonParameters>]
Format-Xml [-Path] <String> [-Indent <Int32>] [-Character <Char>] [<CommonParameters>]
Format-Xml [-Text] <String> [-Indent <Int32>] [-Character <Char>] [<CommonParameters>]
Runs an XmlDocument through an auto-indenting XmlWriter
[xml]$xml = get-content Data.xml
C:\PS>Format-Xml $xml
Formats the contents of Data.xml
get-content Data.xml | Format-Xml
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)
ls *.xml | Format-Xml
The Xml Document
Type: XmlDocument
Parameter Sets: Document
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
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
{{ Fill Text Description }}
Type: String
Parameter Sets: Text
Aliases: PsText
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
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
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
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.