C:\Program" /> C:\Program" /> C:\Program"/>

Printing XML data in a DATA GRID VIEW C#

59 views Asked by At
 <Tools ID="RDM">
  <ButtonTool>
    <Item ID="IS" TYPE="IS" NAME="IS" COLUMN_ID="ID" ORDERNO="UID" />
    <Item ID="CS" TYPE="PROC" NAME="ABC">
      <Path>C:\ProgramData\base\VLaunch.exe</Path>
      <Parameter>/USERID=acc /USERPASS=abc /ID=ITEM /QUERY</Parameter>
    </Item>
    <Item ID="APPLICATION" TYPE="PROC" NAME="XYZ">
      <Path>D:\ACT\bin\ACTLancher.exe</Path>
      <Parameter>%U %I -APPLICATION $$PATIENTID$$ CT $$RDM_UID$$</Parameter>
    </Item>
    <Item ID="REPO" TYPE="PROC" NAME="AAA">
      <Path>C:\app\LUC\Launcher.exe</Path>
      <Parameter>/USERID=acc /USERPASS=abc /ID=ITEM</Parameter>
    </Item>
  </ButtonTool>
</Tools>

I'm new to this field and facing some issues, this is a xml file which I want to print in a data grid view, I'm able to print the value of item tag in the grid but not able to print the path and parameter tag in the grid. I tried using SelectingsingleNode but it will always print the first path and parameter in the grid. the code I used to until now is as follows....any help will be appreciated

   XmlNodeList nl = _doc.SelectNodes("Tools/ButtonTool/Item");
                for (int i = 0; i < nl.Count; i++)
                {
                    string sType = base.Com.GetAttri(nl[i], "TYPE", "");
                    if (sType == "RIS")
                    {
                        _dt.Rows.Add(base.Com.GetAttri(nl[i], "ID", ""),
                                  base.Com.GetAttri(nl[i], "TYPE", ""),
                                  base.Com.GetAttri(nl[i], "NAME", ""),
                                  base.Com.GetAttri(nl[i], "COLUMN_ID", ""),
                                  base.Com.GetAttri(nl[i], "ORDERNO", ""));
                    }
                    else
                    {
                        //for (int j = 0; j < nl.Count; j++)
                        //{
                        XmlNodeList pl = _doc.SelectNodes("Tools/ButtonTool/Item/Path");
                        txtPath.Text = pl.ToString();
                        XmlNode ppl = _doc.SelectSingleNode("Tools/ButtonTool/Item/Parameter");
                        txtUser.Text = ppl.InnerText;
                        //string Path = txtPath.Text;
                        _dt.Rows.Add(base.Com.GetAttri(nl[i], "ID", ""),
                              base.Com.GetAttri(nl[i], "TYPE", ""),
                              base.Com.GetAttri(nl[i], "NAME", ""),
                              base.Com.GetAttri(nl[i], "COLUMN_ID", ""),
                              base.Com.GetAttri(nl[i], "ORDERNO", ""), txtUser.Text, txtPath.Text
                              );
                        //}

                    }

0

There are 0 answers