def write_ioc_string(root, force=False):
root_tag = '<STR_LIT>'<EOL>if not force and root.tag != root_tag:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(root_tag))<EOL><DEDENT>default_encoding = '<STR_LIT:utf-8>'<EOL>tree = root.getroottree()<EOL>try:<EOL><INDENT>encoding = tree.docinfo.encoding<EOL><DEDENT>except:<EOL><INDENT>log.debug('<STR_LIT>')<EOL>encoding = default_encoding<EOL><DEDENT>return et.tostring(tree, encoding=encoding, xml_declaration=True, pretty_print=True)<EOL>
Serialize an IOC, as defined by a set of etree Elements, to a String.
:param root: etree Element to serialize.  Should have the tag 'OpenIOC'
:param force: Skip the root node tag check.
:return: