when writing to the buffer my CDATA is not correct.
xx=xml_write([], MyTree, {'MyTree', [], 'This is a global comment'}, Pref);
xmlwrite(xx)
ans =
<?xml version="1.0" encoding="utf-8"?><!--This is a global comment-->
<MyTree><A>txt</A><MyNumber>13</MyNumber>
<MyString>Hello World</MyString>
</MyTree>
when writing to a file it is
>> xml_write('xx.xml', MyTree, {'MyTree', [], 'This is a global comment'}, Pref);
>> type ('xx.xml')
<?xml version="1.0" encoding="UTF-8"?>
<!--This is a global comment-->
<MyTree><![CDATA[<A>txt</A>]]><MyNumber>13</MyNumber>
<MyString>Hello World</MyString>
</MyTree>