--- XmlPeekTask.cs.old	Fri Dec 26 15:21:14 2003
+++ XmlPeekTask.cs.new	Wed Feb 18 16:16:03 2004
@@ -67,14 +67,40 @@
     /// </example>
     [TaskName("xmlpeek")]
     public class XmlPeekTask : Task  {
+
         #region Private Instance Fields
 
         private FileInfo _xmlFile;
         private int _nodeIndex = 0;
         private string _property;
         private string _xPath;
+        private NamespaceElement[] _namespaces = null;
 
         #endregion Private Instance Fields
+		 
+        public class NamespaceElement : Element {
+            private string _name;
+            private string _namespace;
+
+            /// <summary>
+            /// Prefix of namespace which is used in XPath expression.
+            /// </summary>
+            [TaskAttribute("name", Required=true)]
+            [StringValidator(AllowEmpty=false)]
+            public string Prefix {
+                get { return _name; }
+                set { _name= value; }
+            }
+
+            /// <summary>
+            /// Associated XML namespace URI.
+            /// </summary>
+            [TaskAttribute("ns", Required=true)]
+            [StringValidator(AllowEmpty=false)]
+            public string Namespace {
+                get { return _namespace; }
+                set { _namespace= value; }
+            }
+        }        
 
         #region Public Instance Properties
         
@@ -119,6 +151,17 @@
             get { return _xPath; }
             set { _xPath = value; }
         }
+
+        /// <summary>
+        /// Array of namespace definitions.
+        /// </summary>
+        [BuildElementArray("namespace", ElementType=typeof(NamespaceElement))]
+        public NamespaceElement[] Namespaces {
+            set {
+				_namespaces = new NamespaceElement[value.Length];
+				value.CopyTo(_namespaces,0);
+			}
+		}
         
         #endregion Public Instance Properties
 
@@ -127,19 +170,36 @@
         /// <summary>
         /// Executes the XML peek task.
         /// </summary>
-        protected override void ExecuteTask() {
-            Log(Level.Info, LogPrefix + "Peeking at '{0}' with XPath expression '{1}'.", 
-                XmlFile.FullName,  XPath);
-
-            // ensure the specified xml file exists
-            if (!XmlFile.Exists) {
-                throw new BuildException(string.Format(CultureInfo.InvariantCulture, 
-                    "XML file '{0}' does not exist.", XmlFile.FullName), Location);
-            }
-
+        protected override void ExecuteTask() 
+        {
+			Properties[Property] = ExecutePeek();
+        }
+
+		public string ExecutePeek() {
+			if(_xmlFile!=null)
+			{
+	            Log(Level.Info, LogPrefix + "Peeking at '{0}' with XPath expression '{1}'.", 
+    	            XmlFile.FullName,  XPath);
+
+        	    // ensure the specified xml file exists
+            	if (!XmlFile.Exists) {
+	                throw new BuildException(string.Format(CultureInfo.InvariantCulture, 
+    	                "XML file '{0}' does not exist.", XmlFile.FullName), Location);
+        	    }
+			}
+			
             try {
                 XmlDocument document = LoadDocument(XmlFile.FullName);
-                Properties[Property] = GetNodeContents(XPath, document, NodeIndex);
+				 return GetNodeContents(XPath, document, NodeIndex);
             } catch (BuildException ex) {
                 throw ex; // Just re-throw the build exceptions.
             } catch (Exception ex) {
@@ -189,7 +251,14 @@
             XmlNodeList nodes;
 
             try {
-                nodes = document.SelectNodes(xpath);
+                XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
+                if(_namespaces!=null) {
+                    foreach(NamespaceElement ns in _namespaces) {
+                        nsmgr.AddNamespace(ns.Prefix,ns.Namespace);
+                    }
+                }
+                Log(Level.Error,nsmgr.ToString());
+                nodes = document.SelectNodes(xpath,nsmgr);
             } catch (Exception ex) {
                 throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                     "Failed to select node with XPath expression '{0}'.", xpath), 

