Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Multiple XML data in datagridview

Simdi_JinkinsSimdi_Jinkins NigeriaMember Posts: 1
edited April 2016 in C#

My query to a large Xml Database

var query = DOC.Descendants("entry").Where(f => f.Element("url").Value.Contains("example"));
returns multiple xml Data

I display the data using a richtextbox

foreach (XElement result in query)
        {richTextBox1.Text += Environment.NewLine + Environment.NewLine + result; }

One xml data looks like this:

<target>Internal Revenue Service</target>

As you can see its rather complex,some of the Children nodes have other children that contain values. My Questions are :
1) How can i put all this values neatly into a Datagridview.
2) There are multiple of this exact format of xml.How can i add each as a new column in the Datagrid.
3)How can i improve performance as my queries may return more than 50 of this xml data.

Please Help me.Thank you in Advance.

What I have tried:

I have tried the following code:

foreach (XElement result in query)


        string display = result.ToString();

        XmlReader xmlFile;
        xmlFile = XmlReader.Create(new StringReader( display));
        DataSet ds = new DataSet();


            dataGridView1.DataSource = ds.Tables[0];


But it only displays the last XmlData and not all the values.Please Help.Thanks in advance

Sign In or Register to comment.