I've been trying the past few days to create a Powershell script that will create a XML file with 2 fields saying the time. Problem is the XML created is CR LF with UTF-8 BOM
and what I need is LF with UTF-8
.
Edit - Following 'LotPings' advise, adding the code at did change the XML to Unix(FL) but it still on UTF8-BOM while it causing me problems. how can i change it from UTF8-BOM to UTF8 ?
I have never handled Powershell and I have no idea how I can achieve that.
# 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()