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;
                }              
            }

 

C# 读取XML

上一篇:C#中的元组对象Tuple


下一篇:Hasse神舟笔记本卡logo解决,刷BIOS方法,教你修复神船