public XMLroot ReadXMLdata(string xmlfile) { //string readPathname = @"D:\ARRAY_APCSPCDT.xml"; XmlSerializer deserializer = new XmlSerializer(typeof(XMLroot)); TextReader reader = new StreamReader(xmlfile); try { object obj = deserializer.Deserialize(reader); XMLroot XmlData = (XMLroot)obj; reader.Close(); return(XmlData); } catch (Exception ex) { MessageBox.Show($"{nameof(ReadXMLdata)}: XML file {xmlfile} read fail: {ex.Message}", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } }
private void button1_Click(object sender, EventArgs e) { XMLroot xroot = xls.ReadXMLdata(@"D:\ARRAY_APCSPCDT.xml"); }