C# 讀取XML ...
C# 讀取XML
string xml = "<ROWID> <row> <patName>劉榮勝</patName> <sex>1</sex> <age>50歲</age> <examId>16377042||8</examId> <patientId>16543990</patientId> <lodgeDept>消化內科</lodgeDept> <lodgeDoctor>陸德雲</lodgeDoctor> <bedNo>+28</bedNo> <outHosNo>OP0013927016</outHosNo> <inHosNo></inHosNo> <birthday>1968-12-10</birthday> <clinicDiag>測試臨床診斷</clinicDiag> <OEORIDate>2019-08-18</OEORIDate> </row> <row> <patName>劉榮勝</patName> <sex>1</sex> <age>50歲</age> <examId>16377042||7</examId> <patientId>16543990</patientId> <lodgeDept>消化內科</lodgeDept> <lodgeDoctor>陸德雲</lodgeDoctor> <bedNo>無床號</bedNo> <outHosNo>OP0013927016</outHosNo> <inHosNo></inHosNo> <birthday>1968-12-10</birthday> <clinicDiag>慢性胃炎;腸道功能紊亂</clinicDiag> <OEORIDate>2019-08-08</OEORIDate> </row> </ROWID>";
XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(xml); DateTime date = Convert.ToDateTime("2018-01-01"); XmlNodeList PatInfo = xmldoc.SelectNodes("ROWID//row"); foreach (XmlElement element in PatInfo) { DateTime dt = Convert.ToDateTime(element.GetElementsByTagName("OEORIDate")[0].InnerText); if (dt>date) { date = Convert.ToDateTime(element.GetElementsByTagName("OEORIDate")[0].InnerText); textBox1.Text = element.GetElementsByTagName("patientId")[0].InnerText; textBox2.Text = element.GetElementsByTagName("patName")[0].InnerText; textBox3.Text = element.GetElementsByTagName("sex")[0].InnerText; textBox4.Text = element.GetElementsByTagName("age")[0].InnerText; textBox12.Text = element.GetElementsByTagName("examId")[0].InnerText; textBox6.Text = element.GetElementsByTagName("inHosNo")[0].InnerText; textBox5.Text = element.GetElementsByTagName("birthday")[0].InnerText; textBox7.Text = element.GetElementsByTagName("outHosNo")[0].InnerText; textBox8.Text = element.GetElementsByTagName("bedNo")[0].InnerText; textBox9.Text = element.GetElementsByTagName("clinicDiag")[0].InnerText; textBox10.Text = element.GetElementsByTagName("lodgeDept")[0].InnerText; textBox11.Text = element.GetElementsByTagName("lodgeDoctor")[0].InnerText; } }