I have xml file like this
<?xml version="1.0" encoding="UTF-8"?>
<DATA>
<Platform>
<D1>8536</D1>
</Platform>
<Timestamp>
<Create>Friday, August 23, 2019 4:34:18 PM</Create>
</Timestamp>
</DATA>
I want to add an element in <Timestamp>.
My Expectation like this
<?xml version="1.0" encoding="UTF-8"?>
<DATA>
<Platform>
<D1>8536</D1>
</Platform>
<Timestamp>
<Create>Friday, August 23, 2019 4:34:18 PM</Create>
<Info>Started</Info>
</Timestamp>
</DATA>
Here's my attempt so far:
$fileName = "D:\file.xml"
$xmlDoc = [System.Xml.XmlDocument](Get-Content $fileName)
$newXmlEmployeeElement = $xmlDoc.CreateElement("Info")
$newXmlEmployee = $xmlDoc.DATA.Timestamp.AppendChild($newXmlEmployeeElement)
$xmlDoc.Save($fileName)
Anyone can help really appreciated. Thanks