//д�ļ����� public void XMLToDataSetChange() { DataBase db = new DataBase(); DataTable dtTemp = db.ExcuteProcedure("select case when StationHeadState<1 then 0 else 1 end,StationHeadNO from Station_Head_Info"); //DataTable DS = new DataTable(); //for(int x=0;x<9;x++) //{ // DataColumn dc = new DataColumn(x.ToString()); // DS.Columns.Add(dc); //} XmlDocument doc = new XmlDocument(); doc.Load(strXMLPath); //�趨XML�ļ�����Ϊ����ṹ XmlNodeList nodelist = doc.FirstChild.NextSibling.ChildNodes; string strContent = string.Empty; //����XML���ѱ�������������м��Ҫ�任���任֮��д�뵽�ļ����� for (int i = 0; i < nodelist.Count; i++) { //DataRow dr = DS.NewRow(); for (int j = 0; j < nodelist[i].ChildNodes.Count; j++) { if (nodelist[i].ChildNodes[j].InnerText != "x" & j == 5) { //if (dtTemp.Select("StationHeadNO='" + nodelist[i].ChildNodes[j].InnerText.Substring(13) + "'").Length != 0) //{ // strContent += nodelist[i].ChildNodes[j].InnerText.ToString() + "\t"+dtTemp.Select("StationHeadNO='" + nodelist[i].ChildNodes[j].InnerText.Substring(13) + "'")[0][0].ToString() + "\t"; //} //else //{ // strContent += nodelist[i].ChildNodes[j].InnerText.ToString() + "\t"; //} strContent += dtTemp.Select("StationHeadNO='" + nodelist[i].ChildNodes[3].InnerText.Substring(13) + "'")[0][0].ToString() + "\t"; } else { strContent += nodelist[i].ChildNodes[j].InnerText.ToString() + "\t"; } } strContent = strContent + "\r\n"; } DataWrite dw = new DataWrite(XmlDocName, strDateTime, strContent,strFileRoot); }
//ͨ��DataSet������ݲ������ļ� public void FillData() { if (Ds != null) { //string strContent = string.Empty; StringBuilder strContent = new StringBuilder(); for (int i = 0; i < Ds.Rows.Count; i++) { for (int j = 0; j < Ds.Columns.Count; j++) { if (j != Ds.Columns.Count - 1) { // strContent += Ds.Rows[i][j].ToString() + ";"; strContent.Append(Ds.Rows[i][j].ToString() + ";"); } else { //strContent += Ds.Rows[i][j].ToString(); strContent.Append(Ds.Rows[i][j].ToString()); } } //strContent += "\r\n"; strContent.Append("\r\n"); } DataWrite dw = new DataWrite(FileName, DateTime, strContent.ToString(),strFileRoot); } }
//��XML�ļ���д�ļ� public void ReadAndWriteFile() { XmlDocument doc = new XmlDocument(); doc.Load(XmlDocPath);//����XML�ļ� //�趨XML�ļ�����Ϊ����ṹ XmlNodeList nodelist = doc.FirstChild.NextSibling.ChildNodes; string strContent = string.Empty; //����XML���ѱ������������ù̶��ĸ�ʽ��֯���������д�뵽�ļ����� for (int i = 0; i < nodelist.Count; i++) { for (int j = 0; j < nodelist[i].ChildNodes.Count; j++) { if (j != nodelist[i].ChildNodes.Count - 1) { strContent += nodelist[i].ChildNodes[j].InnerText + "\t"; } else { strContent += nodelist[i].ChildNodes[j].InnerText; } } strContent += "\r\n"; } //��Ҫд������д���ļ��� DataWrite dw = new DataWrite(XmlDocName, strDateTime, strContent,strFileRoot); }