+
+ if ( ! class_exists( 'DOMDocument' ) )
+ return false;
+
+ $errors = libxml_use_internal_errors( true );
+ $old_value = null;
+ if ( function_exists( 'libxml_disable_entity_loader' ) ) {
+ $old_value = libxml_disable_entity_loader( true );
+ }
+
+ $dom = new DOMDocument;
+ $success = $dom->loadXML( $response_body );
+
+ if ( ! is_null( $old_value ) ) {
+ libxml_disable_entity_loader( $old_value );
+ }
+ libxml_use_internal_errors( $errors );
+
+ if ( ! $success || isset( $dom->doctype ) ) {
+ return false;
+ }
+
+ $data = simplexml_import_dom( $dom );
+ if ( ! is_object( $data ) )
+ return false;
+
+ $return = new stdClass;
+ foreach ( $data as $key => $value )
+ $return->$key = (string) $value;
+ return $return;