title: XML parsing and automation
body: <p>I have never really had the need to use <code>XML</code> in addition to the automation that I write for work.  Maybe I have been doing it wrong or maybe I have just been ...lucky?</p>
  
  <p>That being said, I am having some troubles with parsing an <code>XML</code>file.  The structure of the <code>XML</code> looks like this:</p>
  
  <pre><code>// I have removed the username and passwords as they are sensitive
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Logins&gt;
     &lt;Login&gt;
        &lt;Username&gt;xxx&lt;/Username&gt;
        &lt;Password&gt;xxx&lt;/Password&gt;
     &lt;/Login&gt;
  ...
  &lt;/Logins&gt;
  </code></pre>
  
  <p>Simple enough.  What I need to do is pull the username and password from each node and put them into two separate variables.  After that, I have some automated code that finds the 3 elements (username, password, submit button), and interacts with them accordingly to log me in.  I then do a smoke test to check for an image and close the browser.  That code is here:</p>
  
  <pre><code>chromeDriver.FindElement(By.Id(@"userNameInput")).SendKeys(userName.ToString());
  chromeDriver.FindElement(By.Id(@"passwordInput")).SendKeys(passWord.ToString());
  chromeDriver.FindElement(By.Id(@"submitButton")).Click();
  Thread.Sleep(10);
  bool isVisible = chromeDriver.FindElement(By.Id(@"logoImage")).Displayed;
  </code></pre>
  
  <p>As you may be able to ascertain, the variables I need to use are, <code>userName</code> and <code>passWord</code>.  The code I have tried, to no avail, (among other attempts) is here:</p>
  
  <pre><code>XDocument rootElement = XDocument.Load(@"C:\Test Data.xml");
  
  IEnumerable&lt;string&gt; textSegment =
     from segment in rootElement.Descendants("Username")
     select (string)segment;
  
  var userName = textSegment;
  </code></pre>
  
  <p>The output I am getting is this:</p>
  
  <blockquote>
    <p>System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String]</p>
  </blockquote>
  
  <p>That is the literal output that is being written/sent to the username field, and I am completely at a loss as to what I am doing wrong at this point.  I know I am doing something wrong when it comes to parsing the <code>XML</code>.</p>