My Problem has been solved. For all who are interested in the code... I finally came up with sth. like this:
open System.Xml
open System.Xml.Linq
let xmlNs = "somenamespaceurl"
let XNameStd name = XName.Get(name, xmlNs)
let InsertIfCondition valueToInsert valueToCheck attributeName (element:XElement) =
if valueToInsert = valueToCheck then
element.Add(XAttribute(XNameStd attributeName,valueToInsert))
let InsertSthToTree(sth:DomainObject) (currentRoot:XElement) =
let element = XElement(XNameStd "MyDomainElementInXML")
currentRoot.Add(element)
InsertIfCondition(sth.BooleanProperty,true,"IsEnabled",element)
let CreateXMLDoc =
let someObj = DomainObject(...)
let doc = XDocument()
InsertSthToTree(doc.Root)
doc
If someone has a more functional-style of doing this I would appreciate any comments.