XDocument does not exist in the System.Xml namespace

I have something that, I think, will probably be a very simple problem, when developing my first WP7 application, I came to the stage of accessing the site api and parsed the XML, however, I stumble while trying to try using XDocument.

I search and find this sample code: Download the XML file from the website in XDocument (Silverlight and Windows Phone 7) , but the XDocument type does not exist, I understand that it must exist in the System.Xml namespace that I use, but The error still remains, what did I miss?

Development on Visual Studio 2010 Express for Windows Phone, the code for this class is below:

using System; using System.Net; using System.IO; using System.Xml; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace Application { public class DataRetriever { public void parseNewsXML() { WebClient client = new WebClient(); client.OpenReadCompleted += (sender, e) => { if (e.Error != null) return; Stream str = e.Result; XDocument xdoc = XDocument.Load(str); }; } } 

Exact error: Error 1 Could not find the name of the type or namespace "XDocument" (do you miss the using directive or assembly reference?)

Thanks in advance

+7
source share
1 answer

For Silverlight, this class is located in System.Xml.Linq.dll , according to MSDN - add a link to System.Xml.Linq.dll . You will also need the using directive at the top of your code file:

 using System.Xml.Linq; 

(these are the same two sentences that the compiler makes: "you did not specify a usage directive or an assembly reference?")

+16
source

All Articles