Howdy, Stranger!

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

Categories

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:

<entry>
<url><![CDATA[http://triada.kh.ua/made/?email=abuse@example.com</url>
<phish_id>3779980</phish_id>
<phish_detail_url>http://www.phishtank.com/phish_detail.php?phish_id=3779980</phish_detail_url>
<details>
<detail>
  <ip_address>93.190.41.34</ip_address>
  <cidr_block>93.190.40.0/21</cidr_block>
  <announcing_network>6849</announcing_network>
  <rir>ripencc</rir>
  <detail_time>2016-01-24T01:00:58+00:00</detail_time>
</detail>
</details>
<submission>
<submission_time>2016-01-22T22:42:56+00:00</submission_time>
</submission>
<verification>
<verified>yes</verified>
<verification_time>2016-03-28T14:15:01+00:00</verification_time>
</verification>
<status>
<online>yes</online>
</status>
<target>Internal Revenue Service</target>
</entry>

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();

        ds.ReadXml(xmlFile);

            dataGridView1.DataSource = ds.Tables[0];


    }      

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

Tagged:
Sign In or Register to comment.