XML - empty elements handling.

Hi all,

I am writing my first Powershell script to modify an XML configuration file that I have no control over the format. It has empty elements listed as follows:-


If I simply open the above XML document and save it as follows:-

$xml = [xml](Get-Content "xmltest.xml")

Then the empty TEST element is now split over 2 lines now. Unfortunately this then causes issues with the program which then consumes this XML file (again which I have no control over). Is there anyway to prevent Powershell from doing this?

Thanks in advance.