I read through this post.
I have this XML:
<?xml version="1.0" encoding="utf-8" ?>
<Export version="" srcSys="" dstSys="" srcDatabase="" timeStamp="">
</Export>
This is what i tried, but with no luck:
var xml = XElement.Parse(BuyingModule.Properties.Resources.Export);
Func<XElement, string, string> GetAttribute = (e, property) => e.Elements("property").Where(p => p.Attribute("name").Value == property).Single().Value;
var query = from record in xml.Elements("Export")
select record;
var prop = GetAttribute(query.FirstOrDefault(), "version");
How do i access to properties of the “Export” Node?
I need to set those properties
The
Exportelement doesn’t have apropertieselement, which is what yourGetAttributemethod is trying to find.My guess is you actually want:
It’s not clear to me why you’ve used a query expression and a delegate here – it’s just things more complicated than you need. But
Attribute(XName)is probably what you were missing…