Did you try the Microsoft sample code for writing?
https://code.msdn.microsoft.com/XmlL...hId=1720047283
There is a code and there is a XML-file example.