c# - loading multiple xml files in to datagrid -


i have list of xml files. (reading 1 directory) want show records present in each xml files in datagrid.

here code same ( xaml file)

  <datagrid autogeneratecolumns="false" itemssource="{binding path=elements[testresult]}"  x:name="datagrid" margin="10,0,-1,0">                         <datagrid.columns>                             <datagridtextcolumn header="testcaseid" binding="{binding path=attribute[testcaseid].value}" />                             <datagridtextcolumn header="outcome" binding="{binding path=attribute[outcome].value}"/>                             <datagridtextcolumn header="duration" binding="{binding path=attribute[duration].value}"/>                             <datagridtextcolumn header="comment" binding="{binding path= attribute[comment].value}"/>                         </datagrid.columns>                     </datagrid> 

testresult class

class testresult {               [xmlattribute("testcaseid")]         public string testcaseid { get; set; }          [xmlattribute("outcome")]         public string outcome { get; set; }          [xmlattribute("duration")]         public string duration { get; set; }          [xmlattribute("comment")]         public string comment { get; set; }     } here code loading each file in datagrid  

however can able see last file data

  foreach (string item in files)         {             var peoplelist = xelement.load(item);            this.datagrid.datacontext = peoplelist;          } 

here 1 xml file

 <testresults url="https://google.com/" startdatetime="2016-11-11t14:52:25.2499848+05:30"> <testresult testcaseid="smoke_21949" outcome="pass" duration="00:03:09.9335101" comment="" /> <testresult testcaseid="smoke_31234" outcome="pass" duration="00:02:56.1503179" comment="" /> </testresults> 

you need create list , add list,

var peoplelist = new list<xelement>(); foreach (string item in files)     {        peoplelist.add(xelement.load(item));                } this.datagrid.datacontext = peoplelist; 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -