Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

C# load xml to datagridview by attribute

$
0
0

Hi guys,

i have the following XML file.

<?xml version="1.0" encoding="utf-8" ?>
<DEALS>
<DEAL ID="22" ISBN="0-7888-1623-3" Screenplay="Mary Kaplan" Title ="Mr Gentleman" Director = "Jonathan Jones">
<ALLOCATION DEMANDE="5000" CODE="72" PRICE="25.00">2500</ALLOCATION>
<ALLOCATION DEMANDE="7000" CODE="75" PRICE="35.00">4000</ALLOCATION>
</DEAL>
<DEAL ID="23" ISBN="1-7988-1623-3" Screenplay="Joe DoeTitle ="Nothing Much" Director = "Listentome">
<ALLOCATION DEMANDE="3300" CODE="72"  PRICE="15.00">2500</ALLOCATION>
</DEAL>
</DEALS>

I have this code to load my xmldata to the datagridview

        private void button2_Click(object sender, EventArgs e)
        {
            DataTable dT = GetDataTableFromDGV(dataGridView1);
            DataSet dS = new DataSet();
            dS.Tables.Add(dT);
            dS.WriteXml(File.OpenWrite("Data.xml"));

        }

My question is how do i load a section of the Data.xml based on attribude.  For example, I want to load the data from the attribute ID="23" only.

Basically this chunk.

How do i do this?

Thank you


Please do not forget to click “Vote as Helpful” if the reply helps/directs you toward your solution and or "Mark as Answer" if it solves your question. This will help to contribute to the forum.


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>