You are on page 1of 3

using System;

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

namespace ReadXml
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

DataSet _ds = null;


private void button1_Click(object sender, EventArgs e)
{
_ds = new DataSet();
_ds.ReadXml("E:\\AIF_26049_20181209_00000004.xml");
comboBox1.Items.Clear();
for (int i = 0; i < _ds.Tables.Count; i++)
{
comboBox1.Items.Add(_ds.Tables[i].TableName);
}
dataGridView1.DataSource = _ds;

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)


{
if (_ds != null)
{
if (_ds.Tables[comboBox1.SelectedIndex] != null)
{
dataGridView1.DataSource = _ds.Tables[comboBox1.SelectedIndex];
}
}
}
string sName;
string sValue;
List<string> lsdd = new List<string>();

private void button2_Click(object sender, EventArgs e)


{
XmlDocument doc = new XmlDocument();
doc.Load("E:\\AIF_26049_20181209_00000004.xml");

XmlNode main = doc.DocumentElement.ChildNodes[0];


foreach (XmlNode ticket in main.ChildNodes)
{
XmlNode header = ticket.ChildNodes[0];
string asName = header.Name;
string asValue = header.Value;

foreach (XmlNode hdp in header.ChildNodes)


{
if (hdp.Name != "LocalCurrency")
{

XmlNode theader = hdp.ChildNodes[0];

sName = hdp.Name.ToString();
sValue = theader.Value.ToString();
if (hdp.Name == "TransNum")
{
//MessageBox.Show(sValue);
}
}

foreach (XmlNode ticketItem in header.ChildNodes)


{
foreach (XmlNode combo in ticket.ChildNodes)
{
if(combo.Name=="TicketItem")
{
foreach (XmlNode Titem in combo.ChildNodes)
{

switch (Titem.Name)
{
case "Combo":

foreach (XmlNode comboItemProp in


Titem.ChildNodes)
{

if (comboItemProp.Name !=
"ComboItem")
{
string ssName =
comboItemProp.Name;
string ssValue =
comboItemProp.Value;
}
else
{
foreach (XmlNode comboItem in
Titem.ChildNodes)
{
string sssame =
header.Name;
string sssValue =
header.Value;
}
}
}
break;
case "Item":

XmlNode xitem = combo.ChildNodes[0];


foreach (XmlNode item in
xitem.ChildNodes)
{
XmlNode uitem = item.ChildNodes[0];
string sssame = item.Name;
string sssValue = uitem.Value;
string t = sssame + " " +
sssValue;

break;
}
}
}
}
}
}
}
}
}
}

You might also like