diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index 9e14812..cfc7c8c 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -1028,91 +1028,19 @@ function _filter_tips($format_id, $long = FALSE) {
 }
 
 /**
- * Parses an HTML snippet and returns it as a DOM object.
- *
- * This function loads the body part of a partial (X)HTML document
- * and returns a full DOMDocument object that represents this document.
- * You can use filter_dom_serialize() to serialize this DOMDocument
- * back to a XHTML snippet.
+ * Parses an HTML snippet and returns it as a SimpleXML object.
  *
  * @param $text
  *   The partial (X)HTML snippet to load. Invalid mark-up
  *   will be corrected on import.
  * @return
- *   A DOMDocument that represents the loaded (X)HTML snippet.
+ *   A SimpleXML object that represents the loaded (X)HTML snippet.
  */
 function filter_dom_load($text) {
   $dom_document = new DOMDocument();
   // Ignore warnings during HTML soup loading.
-  @$dom_document->loadHTML('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>' . $text . '</body></html>');
-
-  return $dom_document;
-}
-
-/**
- * Converts a DOM object back to an HTML snippet.
- *
- * The function serializes the body part of a DOMDocument
- * back to an XHTML snippet.
- *
- * The resulting XHTML snippet will be properly formatted
- * to be compatible with HTML user agents.
- *
- * @param $dom_document
- *   A DOMDocument object to serialize, only the tags below
- *   the first <body> node will be converted.
- * @return
- *   A valid (X)HTML snippet, as a string.
- */
-function filter_dom_serialize($dom_document) {
-  $body_node = $dom_document->getElementsByTagName('body')->item(0);
-  $body_content = '';
-
-  foreach ($body_node->getElementsByTagName('script') as $node) {
-    filter_dom_serialize_escape_cdata_element($dom_document, $node);
-  }
-
-  foreach ($body_node->getElementsByTagName('style') as $node) {
-    filter_dom_serialize_escape_cdata_element($dom_document, $node, '/*', '*/');
-  }
-
-  foreach ($body_node->childNodes as $child_node) {
-    $body_content .= $dom_document->saveXML($child_node);
-  }
-  return preg_replace('|<([^> ]*)/>|i', '<$1 />', $body_content);
-}
-
-/**
- * Adds comments around the <!CDATA section in a dom element.
- *
- * DOMDocument::loadHTML in filter_dom_load() makes CDATA sections from the
- * contents of inline script and style tags.  This can cause HTML 4 browsers to
- * throw exceptions.
- *
- * This function attempts to solve the problem by creating a DocumentFragment
- * and immitating the behavior in drupal_get_js(), commenting the CDATA tag.
- *
- * @param $dom_document
- *   The DOMDocument containing the $dom_element.
- * @param $dom_element
- *   The element potentially containing a CDATA node.
- * @param $comment_start
- *   String to use as a comment start marker to escape the CDATA declaration.
- * @param $comment_end
- *   String to use as a comment end marker to escape the CDATA declaration.
- */
-function filter_dom_serialize_escape_cdata_element($dom_document, $dom_element, $comment_start = '//', $comment_end = '') {
-  foreach ($dom_element->childNodes as $node) {
-    if (get_class($node) == 'DOMCdataSection') {
-      // See drupal_get_js().  This code is more or less duplicated there.
-      $embed_prefix = "\n<!--{$comment_start}--><![CDATA[{$comment_start} ><!--{$comment_end}\n";
-      $embed_suffix = "\n{$comment_start}--><!]]>{$comment_end}\n";
-      $fragment = $dom_document->createDocumentFragment();
-      $fragment->appendXML($embed_prefix . $node->data . $embed_suffix);
-      $dom_element->appendChild($fragment);
-      $dom_element->removeChild($node);
-    }
-  }
+  @$dom_document->loadHTML($text);
+  return simplexml_load_load($dom_document);
 }
 
 /**
@@ -1582,7 +1510,7 @@ function _filter_url_tips($filter, $format, $long = FALSE) {
  * Scan input and make sure that all HTML tags are properly closed and nested.
  */
 function _filter_htmlcorrector($text) {
-  return filter_dom_serialize(filter_dom_load($text));
+  return filter_html_simplexml()->asXml();
 }
 
 /**
