C# Parallel.Foreach with XML
<p>I'm brand new to C# though have some minor experience with other languages and have hit a brick wall.</p>

<p>The code below works exactly as expected:</p>

<pre><code>XmlDocument doc = new XmlDocument();
doc.Load("config.xml");
foreach (XmlNode node in doc.DocumentElement.ChildNodes)
{
   string name = node.Attributes["name"].Value;
   string ips = node.Attributes["ip"].Value;
   string port = node.Attributes["port"].Value;
   Console.WriteLine(name + " | " + ips + ":" + port);
}
</code></pre>

<p>I get out exactly what I am expecting with zero errors, however the following code has got me stumped. I am hoping someone can explain what I am doing wrong as I feel like I am perhaps missing something fundamental.</p>

<pre><code>XmlDocument doc = new XmlDocument();
doc.Load("config.xml");
node = doc.DocumentElement.ChildNodes;
Parallel.ForEach(node,
      (item) =&gt; {
      string name = item.Attributes["name"].Value;
      string ips = item.Attributes["ip"].Value;
      string port = item.Attributes["port"].Value;
      Console.WriteLine(name + " | " + ips + ":" + port);
      });
</code></pre>

<p>I am simply trying to run each iteration of the loop in parallel. When I try compile I get the following error: </p>

<p><strong>CS0411    The type arguments for method 'Parallel.ForEach
(IEnumerable, Action)' cannot be inferred from the usage. 
Try specifying the type arguments explicitly.</strong></p>

<p>Example XML below:</p>

<pre><code>&lt;item name="pc01" ip="192.168.0.10" port="80"&gt;&lt;!--PC01--&gt;&lt;/item&gt;
&lt;item name="pc02" ip="192.168.0.11" port="80"&gt;&lt;!--PC02--&gt;&lt;/item&gt;
&lt;item name="pc03" ip="192.168.0.12" port="80"&gt;&lt;!--PC03--&gt;&lt;/item&gt;
&lt;item name="pc04" ip="192.168.0.13" port="80"&gt;&lt;!--PC04--&gt;&lt;/item&gt;
</code></pre>

<p>Any assistance would be greatly appreciated.</p>