-2

I have a xml file like this.

<?xml version="1.0"?>
<Topic TopicName="FxhysS2vY64=">
  <Question>
    <QuestionID>HtjBCldKZg4=</QuestionID>
    <Details>Cg+MCbd9nTpJokauVrxHsyTqcvKCS8ePzHQCpUTVviWxAXriQVLy5w==</Details>
    <Description>x358GtJIXJI=</Description>
    <TrueOrFalse>D2zx2u5cwbo=</TrueOrFalse>
    <Points>W4VYuxBJeaY=</Points>
    <QuestionType>Fr1jj5tmWhMKNIKrHy18Rg==</QuestionType>
    <Caption>Cg+MCbd9nTpJokauVrxHsyTqcvKCS8ePAsNmzBfGJhg=</Caption>
    <TopicID>HtjBCldKZg4=</TopicID>
  </Question>
  <Question>
    <QuestionID>HtjBCldKZg4=</QuestionID>
    <Details>ccX0bHUdtg4ayF/7PfpFHUx9kPAGUBC5xOh1mw1b7d1g0lHifJ6AD49Niw1ipCPp</Details>
    <Description>x358GtJIXJI=</Description>
    <TrueOrFalse>JYEB3R1+ypE=</TrueOrFalse>
    <Points>W4VYuxBJeaY=</Points>
    <QuestionType>Fr1jj5tmWhMKNIKrHy18Rg==</QuestionType>
    <Caption>ccX0bHUdtg4ayF/7PfpFHUx9kPAGUBC5xOh1mw1b7d1g0lHifJ6AD49Niw1ipCPp</Caption>
    <TopicID>HtjBCldKZg4=</TopicID>
  </Question>
</Topic>

I want to put them into datatable and show in gridcontrol in devexpress My gridcontrol enter image description here

So, how can i do this. Thanks so much

Rob
  • 26,989
  • 16
  • 82
  • 98
Thanh Duy
  • 13
  • 1
  • 5
  • 1
    Please refer to any online tutorial to do the basic coding and then ask specific questions. – Sampada Apr 07 '16 at 06:53
  • Yeah, that is another "I am too lazy to learn what I am supposed to do, or read the documentation, please teach me programming" question. – TomTom Apr 07 '16 at 07:10

2 Answers2

0

Try this i think it will help you

    public DataTable ReadXML(string file)
{
    DataTable table = new DataTable("XmlData");
    Stream stream = new  FileStream(file, FileMode.Open, FileAccess.Read);
    table.Columns.Add("Name", typeof(string));
    table.Columns.Add("Power", typeof(int));
    table.Columns.Add("Location", typeof(string));
    table.ReadXml(stream);
    return table;
}

Here is the full reference:

How to read XML into a DataTable?

Community
  • 1
  • 1
Amr Deif
  • 103
  • 1
  • 14
0

Here is a very simply method with very little work. You are reading from a file so no need to use streams.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        const string FILENAME = @"c:\temp\test.xml";
        public Form1()
        {
            InitializeComponent();
            DataSet ds = new DataSet();
            ds.ReadXml(FILENAME);

            dataGridView1.DataSource = ds.Tables[1];
        }
    }
}
jdweng
  • 33,250
  • 2
  • 15
  • 20