0
我得到了令人沮喪的c#問題。我有這樣的XML數據:C#使用while語句中的數據填充listview
<entries>
<schedule>
<flight>UAL9858</flight>
<dep>San Francisco, CA (KSFO)</dep>
<deptime>07:00:00</deptime>
<arr>(URSS)</arr>
<arrtime>20:00:00</arrtime>
<ac>744</ac>
<dur>15:15:00</dur>
<cat>1</cat>
<id>28858</id>
</schedule>
<schedule>
<flight>UAL9857</flight>
<dep>San Francisco, CA (KSFO)</dep>
<deptime>07:00:00</deptime>
<arr>(URSS)</arr>
<arrtime>20:00:00</arrtime>
<ac>777</ac>
<dur>15:15:00</dur>
<cat>1</cat>
<id>28857</id>
</schedule>
<schedule>
<flight>SKW6289</flight>
<dep>San Francisco, CA (KSFO)</dep>
<deptime>19:38:00</deptime>
<arr>Albuquerque, NM (KABQ)</arr>
<arrtime>23:04:00</arrtime>
<ac>CRJ</ac>
<dur>02:26:00</dur>
<cat>1</cat>
<id>10413</id>
</schedule>
</entries>
現在我有每個節點(DEP,deptime,編曲,arrtime,交流,杜爾,貓,ID)一列,我要填充與文本內容的每一行在每個條目之間,每個條目都在它自己的列中。這樣整個xml文檔就會以表格格式顯示。我使用以下格式來用讀取XML信息(調試)一個文本框:
using (XmlReader reader = XmlReader.Create(fullURL))
{
while (reader.Read())
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case "flight":
var flight = reader.ReadElementContentAsString();
textBox3.AppendText(flight + " | ");
break;
case "dep":
var dep = reader.ReadElementContentAsString();
textBox3.AppendText(dep + " | ");
break;
case "deptime":
var deptime = reader.ReadElementContentAsString();
textBox3.AppendText(deptime + " | ");
break;
case "arr":
var arr = reader.ReadElementContentAsString();
textBox3.AppendText(arr + " | ");
break;
case "arrtime":
var arrtime = reader.ReadElementContentAsString();
textBox3.AppendText(arrtime + " | ");
break;
case "ac":
var ac = reader.ReadElementContentAsString();
textBox3.AppendText(ac + " | ");
break;
case "dur":
var dur = reader.ReadElementContentAsString();
textBox3.AppendText(dur + " | ");
break;
case "cat":
var cat = reader.ReadElementContentAsString();
textBox3.AppendText(cat + " | ");
break;
case "id":
var id = reader.ReadElementContentAsString();
textBox3.AppendText(id + " | ");
break;
我將如何完成這個任務?
ASP.net,WinForms,WPF?你在這裏爲你的UI工作? –