method toXML

void toXML(stream stream);

Argumente

Zurückgegebener Wert

This method creates a XML UTF-8 encoding of the dictionary pairs. The pairs in the dictionary are unchanged. This will allow a dictionary to be passed around as text by calling rawStreamReader::readStringTillEndOfStream on the specified stream. The following value types are supported: double, int64, int64, uint32, int32, uint16, int16, uint8, int8, stream, string, time, bool, array, and dictionary. When stream is encountered, it is converted to base 64. The XML declaration is not included in the stream.

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>
*/