diff --git a/views/plugins/views_plugin_style_xml.inc b/views/plugins/views_plugin_style_xml.inc
index 606fe65..6711bee 100644
--- a/views/plugins/views_plugin_style_xml.inc
+++ b/views/plugins/views_plugin_style_xml.inc
@@ -53,6 +53,10 @@ class views_plugin_style_xml extends views_plugin_style {
       'default' => FALSE,
       'translatable' => FALSE
     );
+    $options['is_xml_fragment'] = array(
+      'default' => FALSE,
+      'translatable' => FALSE
+    );
     //$options['action_on_missing_field'] = array('default' => 'none', 'translatable' => FALSE);
     return $options;
   }
@@ -72,7 +76,7 @@ class views_plugin_style_xml extends views_plugin_style {
       '#type' => 'textfield',
       '#title' => t('Root element name'),
       '#default_value' => $this->options['root_element'],
-      '#description' => t('The name of the root element in a raw XML document.'),
+      '#description' => ('The name of the root element in a raw XML document, may be empty.'),
       //'#process' => array('views_process_dependency'),
       //'#dependency' => array('edit-style-options-schema' => array('raw')),
     );
@@ -151,6 +155,12 @@ class views_plugin_style_xml extends views_plugin_style {
       '#default_value' => $this->options['using_views_api_mode'],
       '#description' => t('Not using View API mode means the XML gets output directly and the server ceases normal page processing.  Using it means the server does not cease processing after outputting the JSON.  This allows the Views API to be used with the view without having to prematurely terminate page processing.'),
     );
+    $form['is_xml_fragment'] = array(
+      '#type'           => 'checkbox',
+      '#title'          => ('Is XML fragment'),
+      '#default_value'  => $this->options['is_xml_fragment'],
+      '#description'    => ('If on then no doctype will be printed.'),
+    );
     /*
     $form['action_on_missing_field'] = array(
       '#type'           => 'radios',
diff --git a/views/theme/views_views_xml_style.theme.inc b/views/theme/views_views_xml_style.theme.inc
index da6ffb1..273a8e7 100644
--- a/views/theme/views_views_xml_style.theme.inc
+++ b/views/theme/views_views_xml_style.theme.inc
@@ -24,13 +24,17 @@ function template_preprocess_views_views_xml_style_raw(&$vars) {
   $plaintext_output = $options["plaintext_output"];
   $vars["content_type"] = ($options['content_type'] == 'default') ? 'text/xml' : $options['content_type'];
   $header = $options['header'];
-  $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
+  if (empty($options['is_xml_fragment'])) $xml =  "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
   if ($header) {
     $xml .= $header . "\n";
   }
-  $xml .= "<$root>\n";
+  if (!empty($root)) {
+    $xml .= "<$root>\n";
+  }
   foreach ($rows as $row) {
-    $xml .= ($options['element_output'] == 'nested') ? "  <$top_child_object>\n" : "  <$top_child_object\n";
+    if (!empty($top_child_object)) {
+      $xml .= ($options['element_output'] == 'nested') ? "  <$top_child_object>\n": "  <$top_child_object\n";
+    }
     foreach ($row as $id => $object) {
       if ($options['field_output'] == 'normal') {
         if ($object->label) {
@@ -89,9 +93,13 @@ function template_preprocess_views_views_xml_style_raw(&$vars) {
       }
     }
 
-    $xml .= ($options['element_output'] == 'nested') ? "  </$end_top_child_object>\n" : "/>\n";
+    if (!empty($end_top_child_object)) {
+      $xml .= ($options['element_output'] == 'nested') ? "  </$end_top_child_object>\n": "/>\n";
+    }
+  }
+  if (!empty($endroot)) {
+    $xml .= "</$endroot>\n";
   }
-  $xml .= "</$endroot>\n";
   $vars["xml"] = $xml;
 }
 
