ここ数日、時間を示す 2 つのフィールドを含む XML ファイルを作成する Powershell スクリプトを作成しようとしています。問題は、作成された XML でCR LF with UTF-8 BOM
あり、必要なものは ですLF with UTF-8
。
編集- 「LotPings」のアドバイスに従って、でコードを追加すると XML が Unix(FL) に変更されましたが、問題が発生している間は UTF8-BOM のままです。UTF8-BOM から UTF8 に変更するにはどうすればよいですか?
私は Powershell を扱ったことがなく、それをどのように達成できるかわかりません。
# Set The Formatting
$xmlsettings = New-Object System.Xml.XmlWriterSettings
$xmlsettings.Indent = $true
$xmlsettings.IndentChars = " "
$hour = (Get-Date).hour
$day = (Get-Date).dayofweek
# Checking If Its Too Late
If ($day -eq "Saturday" -and $hour -lt "8")
{
$hour = "00"
}
else
{
if ($day -ne "Saturday" -and $hour -lt "7")
{
$hour = "00"
}
}
# Set the File Name Create The Document
$XmlWriter = [System.XML.XmlWriter]::Create("S:\NowPlaying\Ch0-News13.xml", $xmlsettings)
# Start the Root Element
$xmlWriter.WriteStartElement("track")
$xmlWriter.WriteElementString("name",$hour.ToString()+":00" + "News Flash of")
$xmlWriter.WriteElementString("artist","News Channel")
$xmlWriter.WriteEndElement() # <-- End <Track>
# End, Finalize and close the XML Document
$xmlWriter.WriteEndDocument()
$xmlWriter.Flush()
$xmlWriter.Close()