using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Xml;
using System.IO;
using System.Windows.Forms;

namespace ABC
{
    class Xml_control
    {
        public DataSet read_xml(string _xmlfile)
        {
            DataSet ds2 = new DataSet();
            ds2.ReadXml(_xmlfile);
            return ds2;
        }
        public DataSet read_xml_toa(string _xmlfile)
        {

            StreamReader reader = new StreamReader(_xmlfile);
            DataSet ds2 = new DataSet();
            ds2.ReadXml(_xmlfile);
            return ds2;
        }
        public void add_Xml()
        {
           
        }
        public void edit_xml(string _xmlfile, string ID, int index_row)
        {
          
        }
        public void delete_xml_node(string _xmlfile, string ID)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(_xmlfile);
            XmlNodeList aNodes = doc.SelectNodes("/NewDataSet/Table");
            foreach (XmlNode node1 in aNodes)
            {
                if (node1.ChildNodes[0].InnerText == ID)
                {
                    node1.RemoveAll();
                    doc.DocumentElement.RemoveChild(node1);
                    break;
                }
            }
            try
            {
                doc.Save(_xmlfile);
            }
            catch
            {
            }
        }


        public void delete_xml_nodeAll(string _xmlfile)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(_xmlfile);
            XmlNodeList aNodes = doc.SelectNodes("/NewDataSet/Table");
            foreach (XmlNode node1 in aNodes)
            {
               
                    node1.RemoveAll();
                   doc.DocumentElement.RemoveChild(node1);
            }
            try
            {
                doc.Save(_xmlfile);
            }
            catch
            {
            }
        }
    }
}
