标签:gets ESS str ring nal length rgba ext ddd
XML 文件解析
public DataTable XMLParse(string POAddFile) { DataTable addDt = _GetPOAddTable(); FileStream fr = null; try { XmlDocument doc; doc = new XmlDocument(); XmlNodeList poRoot; fr = new FileStream(POAddFile, FileMode.Open, FileAccess.Read, FileShare.None, 8, false); byte[] bt = new byte[fr.Length]; fr.Read(bt, 0, bt.Length); fr.Close(); string sFileContent = Encoding.UTF8.GetString(bt); DataRow addRow; doc.LoadXml(sFileContent); string MyInfo = sFileContent; string[] arrylist = MyInfo.Split(‘\t‘); //result = ReadIn(arrylist, File_Name, getFile_Time, file_createtime); poRoot = doc.SelectSingleNode("A").ChildNodes; foreach (XmlNode tmpNode in poRoot) { addRow = addDt.NewRow(); addRow["AA"] = tmpNode.Attributes["A"].Value; addRow["BB"] = tmpNode.SelectSingleNode("B").SelectSingleNode("BB").InnerText; addRow["CC"] = tmpNode.Attributes["CC"].Value; addDt.Rows.Add(addRow); } } catch (Exception ex) { } finally { fr.Close(); } return addDt; }
调用方法:
public DataTable _GetPOAddTable() { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("AA", typeof(string))); dt.Columns.Add(new DataColumn("BB", typeof(string))); dt.Columns.Add(new DataColumn("CC", typeof(string))); return dt; }
标签:gets ESS str ring nal length rgba ext ddd
原文地址:https://www.cnblogs.com/wml-it/p/14729511.html