Reading multiple XML attributes
<p>I'm trying to get information from XML library (file below) using C# in Visual Studio.</p>

<pre><code>&lt;buttons&gt;
&lt;measurement&gt;
    &lt;scan id="0" time="20 53 06"&gt;
        &lt;q address="40" state="0"/&gt;
        &lt;q address="41" state="0"/&gt;
        &lt;q address="42" state="1"/&gt;
        &lt;q address="43" state="0"/&gt;
        &lt;q address="44" state="1"/&gt;
        &lt;q address="45" state="1"/&gt;
        &lt;q address="46" state="1"/&gt;
        &lt;q address="47" state="1"/&gt;
    &lt;/scan&gt;
&lt;/measurement&gt;
&lt;measurement&gt;
    &lt;scan id="1" time="20 53 07"&gt;
        &lt;q address="40" state="0"/&gt;
        &lt;q address="41" state="0"/&gt;
        &lt;q address="42" state="0"/&gt;
        &lt;q address="43" state="0"/&gt;
        &lt;q address="44" state="1"/&gt;
        &lt;q address="45" state="0"/&gt;
        &lt;q address="46" state="0"/&gt;
        &lt;q address="47" state="0"/&gt;
    &lt;/scan&gt;
&lt;/measurement&gt;
&lt;measurement&gt;
    &lt;scan id="2" time="20 53 08"&gt;
        &lt;q address="40" state="0"/&gt;
        &lt;q address="41" state="1"/&gt;
        &lt;q address="42" state="0"/&gt;
        &lt;q address="43" state="1"/&gt;
        &lt;q address="44" state="1"/&gt;
        &lt;q address="45" state="0"/&gt;
        &lt;q address="46" state="0"/&gt;
        &lt;q address="47" state="1"/&gt;
    &lt;/scan&gt;
&lt;/measurement&gt;
&lt;measurement&gt;
    &lt;scan id="3" time="20 53 09"&gt;
        &lt;q address="40" state="1"/&gt;
        &lt;q address="41" state="0"/&gt;
        &lt;q address="42" state="0"/&gt;
        &lt;q address="43" state="1"/&gt;
        &lt;q address="44" state="1"/&gt;
        &lt;q address="45" state="0"/&gt;
        &lt;q address="46" state="1"/&gt;
        &lt;q address="47" state="0"/&gt;
    &lt;/scan&gt;
&lt;/measurement&gt;
&lt;measurement&gt;
    &lt;scan id="4" time="20 53 10"&gt;
        &lt;q address="40" state="0"/&gt;
        &lt;q address="41" state="0"/&gt;
        &lt;q address="42" state="1"/&gt;
        &lt;q address="43" state="1"/&gt;
        &lt;q address="44" state="1"/&gt;
        &lt;q address="45" state="1"/&gt;
        &lt;q address="46" state="0"/&gt;
        &lt;q address="47" state="0"/&gt;
    &lt;/scan&gt;
&lt;/measurement&gt;
&lt;measurement&gt;
    &lt;scan id="5" time="20 53 11"&gt;
        &lt;q address="40" state="1"/&gt;
        &lt;q address="41" state="1"/&gt;
        &lt;q address="42" state="1"/&gt;
        &lt;q address="43" state="0"/&gt;
        &lt;q address="44" state="0"/&gt;
        &lt;q address="45" state="0"/&gt;
        &lt;q address="46" state="1"/&gt;
        &lt;q address="47" state="0"/&gt;
    &lt;/scan&gt;
&lt;/measurement&gt;
&lt;measurement&gt;
    &lt;scan id="6" time="20 53 12"&gt;
        &lt;q address="40" state="0"/&gt;
        &lt;q address="41" state="1"/&gt;
        &lt;q address="42" state="1"/&gt;
        &lt;q address="43" state="0"/&gt;
        &lt;q address="44" state="0"/&gt;
        &lt;q address="45" state="1"/&gt;
        &lt;q address="46" state="1"/&gt;
        &lt;q address="47" state="1"/&gt;
    &lt;/scan&gt;
&lt;/measurement&gt;
&lt;measurement&gt;
    &lt;scan id="7" time="20 53 13"&gt;
        &lt;q address="40" state="1"/&gt;
        &lt;q address="41" state="1"/&gt;
        &lt;q address="42" state="1"/&gt;
        &lt;q address="43" state="1"/&gt;
        &lt;q address="44" state="1"/&gt;
        &lt;q address="45" state="0"/&gt;
        &lt;q address="46" state="1"/&gt;
        &lt;q address="47" state="1"/&gt;
    &lt;/scan&gt;
&lt;/measurement&gt;
</code></pre>

<p></p>

<p>it is my first attempt to do and read xml files.</p>

<p>Hre is what i want to do:<br>
I want to inpud ID and program schould return all q states in array.</p>

<p>Here is what I tried:</p>

<pre><code>using System.Xml;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("Path to my xml");
XmlNodeList titleNodes = xmlDoc.SelectNodes("//buttons/measurment/scan/q");
foreach(XmlNode titleNode in titleNodes)
    Console.WriteLine(titleNode.Attribute["address"]);
Console.ReadKey();
</code></pre>

<p>I know that this code will only display some q atributes in console. I never went furder because it is not working (nothing appears in console window) . And i dont know why. I just don understand this XmlRead, XmlDeocument. I was learnig form here: <a href="http://csharp.net-tutorials.com/xml/introduction/" rel="nofollow">Tutorial</a>. I was folowing every stem and examlpes. Only XmlRead giave something to me. Bu it reads just everything, not specific regions.</p>

<p>Can you show me some examples or solutions?</p>