Convert a PowerShell object to an XML PList.
Originally intended for the conversion of JSON based tmLanguage grammar definitions to the formal tmLanguage PLIST format.
Example based on JSON tmLanguage file.
Get-Content "powershell.tmlanguage.json" | ConvertFrom-Json |
ConvertTo-Plist -Indent "`t" -StateEncodingAs 'UTF-8' |
Set-Content 'out\PowerShellSyntax.tmLanguage' -Encoding 'UTF8'
$grammar_json = Get-Content "powershell.tmlanguage.json" | ConvertFrom-Json
ConvertTo-Plist $grammar_json -Indent "`t" -StateEncodingAs 'UTF-8' |
Set-Content 'out\PowerShellSyntax.tmLanguage' -Encoding 'UTF8'
[xml]$grammar_xml = Get-Content "powershell.tmlanguage.json" | ConvertFrom-Json |
ConvertTo-Plist -Indent "`t" -StateEncodingAs $null
The PowerShell object which possesses the items for the PLIST. This can be any object that can be represented as a PSCustomObject. This parameter may be received from the pipeline.
Omits white space and indented formatting in the output string. Ignores all further indenting and formatting related parameters.
Specifies the indentation to use when generating the XML output. The default is "`t"
(tab), but other usual options are ''
(none), ' '
(4 spaces), but otherwise any string is accepted, and no escaping is performed.
Specifies the encoding to state in the XML header. This does not actually set the encoding as this function does not directly produce encoded output. See the examples above. The default is 'UTF-8'. Specify $null
to remove the encoding
attribute from the header.
Specifies the maximum depth of recursion permitted for the input property list object.
A switch that specifies that the first item level of the PLIST XML is to be indented. Most PLIST files do not have the first item level indented, but a formal XML writer would normally do this.
A switch that specifies an alternate serialization option that converts all enumerations to their string representations.
Maximum encoded <data>
length for keeping value inline, if unspecified, all data will be nested and wrapped, if 0, all data will be inline.
Maximum encoded <data>
length for each nested wrapped line once exceeding FormatDataInlineMaxLength, or 0 for all data to be on a single nested line.
A switch to prevent the indenting of <data>
content when nested/wrapped on separate lines.
The output of this function is a single string ([string]
). Use Out-File or Set-Content and be sure to assign the correct encoding. You may also use the [xml]
accelerator when assigning the output to a variable, and then use XML cmdlets or tools on the result.
Note:
- Escapes only '<', '&' and '>'.
- The PList XML generator should be complete, with regard to item data type handling.