This method creates the dictionary pairs from a XML
UTF-8 encoding that was returned from
toXML.
All pairs are removed from the dictionary first.
var dictObj = shell.serviceManager.basics.dictionary;
dictObj.setValueForKey("Hello World", "name");
dictObj.setValueForKey(false, "isVisible");
var users = shell.serviceManager.basics.array;
users.addValue("john");
users.addValue("tom");
dictObj.setValueForKey(users, "users");
dictObj.setValueForKey(400, "width");
var xmlStream = shell.serviceManager.basics.memoryStream;
dictObj.toXML(xmlStream);
/*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>
*/
dictObj.fromXML(xmlStream);
xmlStream.close();
/*fromXML will remove all the elements first.
The result key/value pair of the dictionary is the following:
name - Hello World
isVisible - 0
users - john
- tom
width - 400
*/