I have a text file with this content:
123asdf
abdfeef
22343sf
dfafdsf
The content of this file is changing.
I want to create an xml file, where one element contains the text file content.
I tried this, but all the content is in the same element:
$Getfile = Get-Content .\DeleteFile.txt
$TimeStamp = [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId(
(Get-Date), 'Taipei Standard Time')
$delete_file = @"
<?xml version="1.0" encoding="UTF-8"?>
<Handling>
<Deleted>
<1>$Getfile</1>
</Deleted>
<TimeStamp>$TimeStamp</TimeStamp>
</Handling>
"@
$delete_file | Out-File .\DeleteFile.xml
Output:
<?xml version="1.0" encoding="UTF-8"?>
<Handling>
<Deleted>
<1>123asdf abdfeef 22343sf dfafdsf</1>
</Deleted>
<TimeStamp>12/04/2019 17:49:06</TimeStamp>
</Handling>
My expectation was that the output would be like this:
<?xml version="1.0" encoding="UTF-8"?>
<Handling>
<Deleted>
<1>123asdf</1>
<2>abdfeef</2>
<3>22343sf</3>
<4>dfafdsf</4>
</Deleted>
<TimeStamp>12/04/2019 17:49:06</TimeStamp>
</Handling>
Can anyone help me please?