prqaprojectxml文件怎樣創建?
prqaproject.xml文件創建方法:
1.首先確認需要創建的Xml文件的路徑和文件名稱,如下:
string file = "D\\Sample.xml";
2.確認XML文件輸出格式及編寫版本:
XmlTextWriter xmlWrite = new XmlTextWriter(file, Encoding.UTF8);
xmlWrite.Formatting = Formatting.Indented;
xmlWrite.WriteStartDocument();
3.確認xml最外層節點名稱:
xmlWrite.WriteStartElement("Sample");
4.輸入你想創建的內容,如果內容較多可以用For循環,我這里已經先把要保存的內容存到list里面,所以直接用For循環:
for (int i = 0; i < Global.DIAlarmSVIDList.Count(); i++)
{
xmlWrite.WriteStartElement("Item");
xmlWrite.WriteAttributeString("ID", List[i].id.ToString());
xmlWrite.WriteAttributeString("ID1", List[i].id1.ToString());
.......
xmlWrite.WriteEndElement();//寫完一條要記得這條語句,下次循環會重啟新一行
}
xmlWrite.WriteEndElement();//xml編寫結束
xmlWrite.Close();//關閉xml