Reputation:
I am trying this code :
string file =@"C:\Program.xml";
XDocument doc = new XDocument(XElement.Load(file));
XElement root = XElement.Parse(doc);
I get the following error :
the best overloaded method match for has some invalid arguments
I really need some help...I've been searchig for some hours for a solution.
Upvotes: 0
Views: 1071
Reputation: 107327
XElement.Parse
is used to load xml from a string, whereas Load
is used to load an xml file - generally you won't need to use both.
I think you may be looking to do something like:
string file = @"C:\Program.xml";
XDocument doc = XDocument.Load(file);
XElement root = doc.Root;
var value = root.Element("foo").Attribute("bar");
Upvotes: 0