<PVdata>
<dev>
<pvname>bbharp1</pvname>
<pvtype>harp</pvtype>
<isactive>true</isactive>
<beamline>J</beamline>
<displaynamex>harp1x</displaynamex>
<displaynamey>harp1y</displaynamey>
</dev>
<dev>
<pvname>bbharp2</pvname>
<pvtype>harp</pvtype>
<isactive>true</isactive>
<beamline>J</beamline>
<displaynamex>harp2x</displaynamex>
<displaynamey>harp2y</displaynamey>
</dev>
<dev>
<pvname>bbharp22</pvname>
<pvtype>harp</pvtype>
<isactive>true</isactive>
<beamline>X2</beamline>
<displaynamex>harp22</displaynamex>
<displaynamey>harp22</displaynamey>
</dev>
</PVData>
Hi
I have the following code reading the above XML
XmlReader Readxml = XmlReader.Create (fname, new XmlReaderSettings ());
dsXML = new DataSet ();
dsXML.ReadXml (Readxml);
dtDevs = new DataTable ();
dtDevs = dsXML.Tables["dev"];
gridHarps.DataSource = dsXML.Tables["dev"]; // just to display data in grid
//Close xml reader
Readxml.Close ();
var w = from r in dtDevs.AsEnumerable()
select r;
foreach (var b in w)
{
tBox.Text += b.pvname + Environment.NewLine; // this fails as it wants b.fields<string>("pvname")
}
>>
I can change the LINQ to:
var w = from r in dtDevs.AsEnumerable()
select new
{
pvname = r.fields<string>("pvname")
pvtype = r.fields<string>("pvtype")
}
However, the XML file can be configured with new "fields", so I cannot use the above.
Thanks
Amien