When the dictionary contains an element type that is not supported by this method, it returns the EE_FAIL error.
var dictionary = shell.serviceManager.basics.dictionary;
dictionary.setValueForKey("Hello World", "name");
dictionary.setValueForKey(false, "isVisible");
var users = shell.serviceManager.basics.array;
users.addValue("john");
users.addValue("tom");
dictionary.setValueForKey(users, "users");
dictionary.setValueForKey(400, "width");
var xmlStream = shell.serviceManager.basics.memoryStream;
dictionary.toXML(xmlStream);
xmlStream.close();
/*The resulting XML in the stream will look like this:
<dictionary>
<string key="name">Hello World</string>
<bool key="isVisible">false</bool>
<compound key="users">
<array>
<string>john</string>
<string>tom</string>
</array>
</compound>
<int32 key="width">400</int32>
</dictionary>
*/