diff --git a/xmlsitemap.generate.inc b/xmlsitemap.generate.inc
index 57c3bc1..15ffdfb 100644
--- a/xmlsitemap.generate.inc
+++ b/xmlsitemap.generate.inc
@@ -447,6 +447,12 @@ function xmlsitemap_rebuild_batch_fetch($entity, &$context) {
   $query->addTag('xmlsitemap_rebuild');
   $query->addMetaData('entity', $entity);
   $query->addMetaData('entity_info', $info);
+
+  // Determin if a node is published.
+  if ($entity == 'node') {
+    $query->propertyCondition('status', 1);
+  }
+
   if ($types = xmlsitemap_get_link_type_enabled_bundles($entity)) {
     $query->entityCondition('bundle', $types, 'IN');
   }
diff --git a/xmlsitemap_node/xmlsitemap_node.module b/xmlsitemap_node/xmlsitemap_node.module
index 3d0e534..1dbfbab 100644
--- a/xmlsitemap_node/xmlsitemap_node.module
+++ b/xmlsitemap_node/xmlsitemap_node.module
@@ -200,10 +200,18 @@ function xmlsitemap_node_create_link(stdClass $node) {
   //unset($access[0][$node->nid]);
   //node_access_acquire_grants($node);
 
+  // Set access flag based on node_access.
+  $access = $node->nid ? xmlsitemap_node_view_access($node, drupal_anonymous_user()) : 1;
+
+  // Check if node is 'published', if not overwrite the 'access' flag to 0 to exclude it from the sitemap.
+  if ($node->status === 0) {
+    $access = 0;
+  }
+
   // The following values must always be checked because they are volatile.
   $node->xmlsitemap['loc'] = $uri['path'];
   $node->xmlsitemap['lastmod'] = count($timestamps) ? max($timestamps) : 0;
-  $node->xmlsitemap['access'] = $node->nid ? xmlsitemap_node_view_access($node, drupal_anonymous_user()) : 1;
+  $node->xmlsitemap['access'] = $access;
   $node->xmlsitemap['language'] = isset($node->language) ? $node->language : LANGUAGE_NONE;
 
   return $node->xmlsitemap;
