--- E:\src\extern\nant-0.85-nightly-2005-12-03\src\NAnt.Core\Tasks\XmlPeekTask.cs	Mon Apr 04 21:08:28 2005
+++ E:\src\extern\nant\src\NAnt.Core\Tasks\XmlPeekTask.cs	Tue Jan 03 13:25:23 2006
@@ -82,6 +82,7 @@
         private string _property;
         private string _xPath;
         private XmlNamespaceCollection _namespaces = new XmlNamespaceCollection();
+        private bool _nonode = true;
 
         #endregion Private Instance Fields
 
@@ -138,6 +139,17 @@
             set { _namespaces = value; }
         }
 
+        /// <summary>
+        /// Suppress error and message when no node is found. Property value is not changed in this case.
+        /// </summary>                
+        [TaskAttribute("failonnonode", Required = false)]
+        [BooleanValidator]
+        public bool FailOnNoMachingNode
+        {
+            get { return _nonode; }
+            set { _nonode = value; }
+        }
+
         #endregion Public Instance Properties
 
         #region Override implementation of Task
@@ -157,7 +169,8 @@
 
             try {
                 XmlDocument document = LoadDocument(XmlFile.FullName);
-                Properties[Property] = GetNodeContents(XPath, document, NodeIndex);
+                string value = GetNodeContents(XPath, document, NodeIndex);
+                if (value != null) Properties[Property] = value;
             } catch (BuildException ex) {
                 throw ex; // Just re-throw the build exceptions.
             } catch (Exception ex) {
@@ -220,14 +233,20 @@
                     Location, ex);
             }
 
-            if (nodes == null || nodes.Count == 0) {
-                throw new BuildException(string.Format(CultureInfo.InvariantCulture, 
-                    ResourceUtils.GetString("NA1156"), xpath), 
-                    Location);
-            }
-
             Log(Level.Info, "Found '{0}' nodes with the XPath expression '{1}'.",
                 nodes.Count, xpath);
+
+            if (nodes == null || nodes.Count == 0) {
+                if (FailOnNoMachingNode)
+                {
+                    throw new BuildException(string.Format(CultureInfo.InvariantCulture, 
+                        ResourceUtils.GetString("NA1156"), xpath), Location);
+                }
+                else
+                {
+                    return null;
+                }
+            }
           
             if (nodeIndex >= nodes.Count){
                 throw new BuildException(string.Format(CultureInfo.InvariantCulture, 
