You can achieve the properly formatted XML string by loading it into an
XDocument
and then just calling
ToString
on it:
WebServiceOutput wso = new WebServiceOutput();
BinaryWriter binWriter = new BinaryWriter(File.Open(@"C:\DAF\config\xyz.xml", FileMode.Create, FileAccess.Write));
binWriter.Write(XDocument.Parse(HierarchyFileContent).ToString());
binWriter.Close();