c# read attribute value
<p>ich have a xml file with the following structure:</p>

<pre><code>&lt;layer1 name="this is layer1"&gt;
  &lt;messages&gt;
    &lt;message name ="com_request"&gt;0&lt;/message&gt;
    &lt;message name="send"&gt;1&lt;/message&gt;
    &lt;message name="request"&gt;2&lt;/message&gt;
  &lt;/messages&gt;
&lt;/layer1&gt;
</code></pre>

<p>I try to collect all the message names in one indexer using the code:</p>

<pre><code>SampleCollection&lt;string&gt; paramCollection = new SampleCollection&lt;string&gt;();

string pathxml = @"C:\myXML.xml";
int j=0;

XmlTextReader xmlin = new XmlTextReader(pathxml);
XmlDocument xmldoc = new XmlDocument();
XmlNode node = xmldoc.ReadNode(xmlin);

foreach (XmlNode item in node.ChildNodes)
{
   paramCollection[j] = item.Attributes["message name"].Value;
   Console.WriteLine(paramCollection[j]);
   j++;
}
</code></pre>

<p>However it doesn't work. Please help.</p>
