0
我需要用我的元素幫助,因爲我想確保我的文件相匹配的要素及以下的Xml文件創建
<employees><employee><employeeId>employeeid</employeeId>
<hireDate>Hiredate</hireDate>
</employee>
<employee>
<employeeId>employeeid</employeeId>
<hireDate>Hiredate</hireDate>
</employee>
<employees>
<staffingHours processType="merge">
<staffHours>
<employeeId>employeeid</employeeId>
<workDays>
<workDay>
<date>date</date>
<hourEntries>
<hourEntry>
<hours>hours</hours>
<jobTitleCode>titlecode</jobTitleCode>
<payTypeCode>paycode</payTypeCode>
</hourEntry></hourEntries>
</workDay>
</workDays>
</staffHours>
</staffingHours>
屬性請記住,我從一個Excel工作表網頁上得到這個數據手冊頁和下面是生成的XML文件中的代碼和我使用的是爲每個環的任何幫助表示讚賞GridView的記錄
XmlElement Empoyees = xmldoc.CreateElement("Employees");
XmlElement newDept = xmldoc.CreateElement("Employee");
XmlElement NurseId = xmldoc.CreateElement("employeeid");
newDept.AppendChild(NurseId);
NurseId.InnerText = row.Cells[0].Text;
XmlElement Firstname = xmldoc.CreateElement("Firstname");
newDept.AppendChild(Firstname);
Firstname.InnerText = row.Cells[1].Text;
//Second node and data source
XmlElement Lastname = xmldoc.CreateElement("Lastname");
newDept.AppendChild(Lastname);
Lastname.InnerText = row.Cells[2].Text;
//Third node and data source
XmlElement Starthour = xmldoc.CreateElement("StartDate");
newDept.AppendChild(Starthour);
Starthour.InnerText = row.Cells[5].Text;
//Fourth node and data source
XmlElement EndDate = xmldoc.CreateElement("EndDate");
newDept.AppendChild(EndDate);
EndDate.InnerText = row.Cells[6].Text;
XmlElement TotalHours = xmldoc.CreateElement("TotalHours");
newDept.AppendChild(TotalHours);
TotalHours.InnerText = row.Cells[10].Text;
XmlElement Starttime = xmldoc.CreateElement("Starttime");
newDept.AppendChild(Starttime);
Starttime.InnerText = row.Cells[11].Text;
XmlElement EndTime = xmldoc.CreateElement("EndTime");
newDept.AppendChild(EndTime);
EndTime.InnerText = row.Cells[12].Text;
//Fourth node and data source
XmlElement HireDate = xmldoc.CreateElement("HireDate");
newDept.AppendChild(HireDate);
HireDate.InnerText = row.Cells[8].Text;
//write to the xml document
xmldoc.DocumentElement.InsertAfter(newDept, xmldoc.DocumentElement.LastChild);
。
什麼編程語言是您使用? Java的? C#? – jwodder
我正在使用C#和VS2017 –
爲什麼你需要幫助?你粘貼的代碼有什麼問題? –