title: Get xml data from external website
body: <p>I have an app that gets a daily feed from an external rss feed (this data is in xml).
  I have a search form that allows users to search my database, however, i would like to use the same searchstring that users enter on my site to search this rss feed, then extract only whats relevant, and display that on my website. </p>
  
  <p>I have been looking at reading xml file using linq using this code:</p>
  
  <pre><code>XElement xelement = XElement.Load("..\\..\\Employees.xml");
  IEnumerable&lt;XElement&gt; employees = xelement.Elements();
  Console.WriteLine("List of all Employee Names along with their ID:");
  foreach (var employee in employees)
  {
      Console.WriteLine("{0} has Employee ID {1}",
          employee.Element("Name").Value,
          employee.Element("EmpId").Value);
  }
  </code></pre>
  
  <p>the problem i have with this is, where in the code do i use a url instead of a file name:</p>
  
  <pre><code>XElement xelement = XElement.Load("..\\..\\Employees.xml");
  </code></pre>
  
  <p>should be:</p>
  
  <pre><code>XElement xelement = XElement.Load("http://www.test.com/file.xml"); 
  </code></pre>
  
  <p>I am thinking maybe i should store the content into an array or something, and check to make sure if the searchString is in it?</p>
  
  <p>I am not sure how to proceed and whats best to use, maybe i shouldn't even use linq??</p>
  
  <p>so using the responses below here is what i have done:</p>
  
  <pre><code>public void myXMLTest()
          {
              WebRequest request = WebRequest.Create("http://www.test.com/file.xml");
              WebResponse response = request.GetResponse();
              Stream dataStream = response.GetResponseStream();
  
              XElement xelement = XElement.Load(dataStream); 
              IEnumerable&lt;XElement&gt; employees = xelement.Elements();
  
  
              MessageBox.Show("List of all Employee Names along with their ID:");
  
              foreach (var employee in employees)
              {
                  MessageBox.Show(employee.Name.ToString()); 
                  /* the above message box gives me this:
                  {http://www.w3.org/2005/Atom}id
                  {http://www.w3.org/2005/Atom}name
                  {http://www.w3.org/2005/Atom}title
                  etc
                  */
                  MessageBox.Show(employee.Element("name").Value);//this gives me error
              }
          }
  </code></pre>