In Synergy, XML_STRING_TYPE can provide a handle to the XML that can be used with %STRING_FROM_HANDLE to get the XML in a string. For example,
string = %string_from_handle(%xml_string_gethandle(XML_STRING_TYPE))
Take special consideration when doing this with an XML handle, because XML handles have binary data in them. As a result, the resulting string will be longer than the length of the XML in the string. For example, i4 = %trim(string) will give a value larger than that of the XML in the document. According to the %XML_STRING_GETSIZE documentation, to get the correct size,
“When processing XML data in a Synergy program, you will probably want to change the XML string into a Synergy memory handle using %XML_STRING_GETHANDLE to get the handle and %XML_STRING_GETSIZE to get its size. You can then use the handle and size in your Synergy program as needed. (For example, you might pass them into the HTTP document transport API.)”
To summarize, the XML portion of a string taken from an XML handle is the result of %XML_STRING_GETSIZE of the string that was used to get the XML handle. To build from the previous example,
i4 = %trim(mystring) ;Gets total size of string with extra characters created from binary
i4 = %xml_string_getsize(XML_STRING_TYPE) ;Gets only the size of the XML portion of the string
This allows you to range into the string and only get the portion that is the XML contents.