c# - I want to selected data from an XML file where element is empty -
this code have worked out, don't know how put selected data gridview in c#.
xdocument doc = xdocument.load(savepath); xelement ele = doc.root.element("boatinslip"); var addsliptogrid = slip in doc.elements("sliplist").elements("slip") slip.element("boatinslip").value == "" select slip; foreach (var slip in addsliptogrid) { //no idea needs come here //(edit) code seemed put 1 char in each cell nullslipgrid.datasource = slip.value; nullslipgrid.databind(); }
this xml data.
<sliplist> <slip> <dock>dock 1</dock> <slipid>2</slipid> <slipwidth>4</slipwidth> <sliplength>12</sliplength> <boatinslip></boatinslip> <slipheight>12</slipheight> <slipdoor>true</slipdoor> </slip> </sliplist>
i want select 'slips' 'boatinslip' = "" , display them gridview nullslipgrid.
(edit 1) result displayed in gridview in 1 column downwards: d o c k
1 2 4 1 2 1 2 t r u e
you can load xml
in dataset
which converted in datatables
, can assign datatable
datasource
girdview
.
dataset ds = new dataset(); ds.readxml(savepath); nullslipgrid.datasource = ds.tables[0]; nullslipgrid.databind();
Comments
Post a Comment