I’m trying to display three columns in a DataGridView.
Here is a sample of my XML:
<root>
<string id = "STRING_ID">
<node1> Some data </node1>
<node2>
<type>data</type>
</node2>
<Translations>
<language name="ARABIC">
<value>Some data</value>
<date_last_changed>7-4-2011</date_last_changed>
</language>
<language name="CHINESE">
...
...
</Translations>
</string>
<string id = "...">
...
...
The first column I want to display is the string id, an attribute value.
The second column I want to display is the <value> data for each string where <language name> is equal to ENGLISH_US.
The third column I want to display is the <value> data for each string where <language name> is equal to the currently selected item in a ComboBox (populated with the names of each of the languages).
This is my Linq query at the moment:
var query_Id = from va in xdoc.Descendants("language")
where va.Attribute("name").Value == ("ENGLISH_US")
select new
{
StringID = va.Parent.Parent.Attribute("id").Value,
English = va.Element("value").Value,
Custom = <incomplete>
};
The problem with this is that while this gives me the first two columns, I cannot think of a way to get the third. In essence, I am searching for a solution that looks something like several selects based on things like WHERE language name = "VALUE" etc. Something simple.
This should work. (You might want to add some error checking on the
SingleOrDefault)