Given the following XML structure:
<?xml version="1.0" encoding="utf-8"?>
<Persons>
<Person>
<Name>Person 1</Name>
<Age>30</Age>
</Person>
<Person>
<Name>Person 2</Name>
<Age>32</Age>
</Person>
</Persons>
I want to add a Person to the collection and I was hoping that could be accomplished with the Xml TypeProvider API.
My approach is the following:
type PersonXmlProvider = XmlProvider<""".\Persons.xml""">
let personsXml = PersonXmlProvider.GetSample()
personsXml.XElement.Add(new PersonXmlProvider.Person("Person 3", 33))
personsXml.XElement.Save("Persons.xml")
What happens: The person is added to the xml collection and written to the file.
Unexpected:
But the encoding is not correct since the XML-Tags are encoded as < and > respectively instead of < and >.
What am I missing?
The documentation says that UTF-8 is the default.
Update
Resulting XML
<?xml version="1.0" encoding="utf-8"?>
<Persons>
<Person>
<Name>Person 1</Name>
<Age>30</Age>
</Person>
<Person>
<Name>Person 2</Name>
<Age>32</Age>
</Person><Person>
<Name>Person 3</Name>
<Age>33</Age>
</Person>
</Persons>