Went back and forth in the question comments a bit, but I'm certain this is the correct answer:
Convert-Xml -Path input.xml -XsltPath style.xslt -OutputPath output.html
However, as you noted, you are on 2.1 of PSCX, which is fairly out of date and doesn't seem to support the -OutputFile
parameter. You can try using the Out-File
cmdlet or redirection operator to output the rendered HTML document to a file like so:
# Using Out-File
Convert-Xml -Path input.xml -XsltPath style.xslt | Out-File output.html
# Using redirection operator (>)
Convert-Xml -Path input.xml -XsltPath style.xslt > output.html
Note that both Out-File
and >
adds a byte-order mark (BOM) to your file. If that is undesirable, you can do this to write the file without the BOM:
# Save the converted HTML to a variable
$htmlDoc = Convert-Xml -Path input.xml -XsltPath style.xslt
# Create a new UTF8 encoding with no BOM
$UTF8EncodingNoBom = New-Object System.Text.UTF8Encoding( $False )
# Write to file using the no-BOM encoding
[System.IO.File]::WriteAllText( 'output.html', $htmlDoc, $UTF8EncodingNoBom )