Format Xml
Zuletzt geändert: 14.03.2026 05:56

Format-Xml #

ÜBERSICHT #

Formatiert XML-Daten mit optionaler XML-Deklaration und speichert das Ergebnis optional in eine Datei.

SYNTAX #

Format-Xml [-XmlString] <string> [-Path] <string> [[-OutFile] <string>] [-RemoveDecoration]
    [-SetDecoration]

BESCHREIBUNG #

Die Funktion Format-Xml lädt XML-Daten aus einer Zeichenfolge oder Datei, formatiert diese übersichtlich mit eingerückter Struktur, fügt bei Bedarf eine XML-Deklaration hinzu oder entfernt sie und gibt das Ergebnis als String zurück oder speichert es in einer Datei.

PARAMETER #

-XmlString #

Type: string

XML-Daten, die als Zeichenfolge übergeben werden.

-Path #

Type: string

Pfad zur Eingabedatei, die XML-Daten enthält.

-OutFile #

Type: string

Optionaler Pfad zur Ausgabe-Datei, in die das formatierte XML geschrieben werden soll.

-RemoveDecoration #

Type: switch

Entfernt die XML-Deklaration, falls vorhanden.

-SetDecoration #

Type: switch

Fügt eine XML-Deklaration hinzu, falls keine vorhanden ist.

BEISPIELE #

# Formatiert das XML mit XML-Deklaration und gibt es zurück.
Format-Xml -XmlString '<root><item>Test</item></root>' -SetDecoration
# Lädt XML aus 'input.xml', entfernt die XML-Deklaration und speichert das Ergebnis in 'output.xml'.
Format-Xml -Path 'input.xml' -OutFile 'output.xml' -RemoveDecoration