title: Loading local xml file in Windows Phone 7 (WP7)
body: <p>I am trying to load up an XML file that lives in my Windows Phone 7 solution. I'd like to know the proper way to include the file in the project and then reference it with code. My current code is giving me an error of </p>
  
  <p>NotSupportedException
  "An exception occurred during a WebClient request."</p>
  
  <p>here is the stub of my WebClient code</p>
  
  <pre><code>WebClient workbenchAdConfigRequest = new WebClient();
  workbenchAdConfigRequest.OpenReadCompleted += new OpenReadCompletedEventHandler(workbenchAdConfigRequest_OpenReadCompleted);
  workbenchAdConfigRequest.OpenReadAsync(new Uri("/SampleData/SampleData.xml", UriKind.Relative));
  </code></pre>
  
  <p>and the event handler is</p>
  
  <pre><code>private void workbenchAdConfigRequest_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
      {
          try
          {
              XElement xml = XElement.Load(e.Result);         
          }
          catch
          {
              //return
          }
      }
  </code></pre>
  
  <p>on the file /SampleData/SampleData.xml I have set the properties to be</p>
  
  <p>Build Action: Embedded Reference
  Copy to Output Directory: Do Not Copy
  Custom Tool: MSBuild:Compile</p>
  
  <p>Can you load a local file from the "file path" of the application?</p>