The problem and solution are described in detail here: http://wordpress.org/support/topic/wp_update_post-strips-css-id-attribute?replies=7
In short, this is due to WordPress' KSES module, which according to WordPress,
...makes sure that only the allowed HTML element names, attribute names and attribute values plus only sane HTML entities will occur in $string.
According to the post, one of the contributors solved this problem by "inserting the following code just before the call to wp_update_post
."
global $allowedposttags;
$allowedposttags['div'] = array('align' => array (), 'class' => array (), 'id' => array (), 'dir' => array (), 'lang' => array(), 'style' => array (), 'xml:lang' => array() );
$allowedposttags['iframe'] = array('src' => array () );
For a global solution, make sure to include:
define('CUSTOM_TAGS', true);