• C# 解析xml格式接口数据


                List OrderInfoEntityList = new List();
                List MedItemList = new List();
                List MedItemDoseList = new List();

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(message);

                XmlNodeList OrderInfoList = doc.SelectNodes("OrderInfo");
                foreach (XmlNode OrderInfo in OrderInfoList)
                {
                    OrderInfoEntity medicineHisData1Entity = new OrderInfoEntity();
                    medicineHisData1Entity.Uuid = Guid.NewGuid().ToString();
                    medicineHisData1Entity.HsptCd = OrderInfo.ChildNodes[0].InnerText;
                    medicineHisData1Entity.DptmtCd = OrderInfo.ChildNodes[1].InnerText;
                    medicineHisData1Entity.WardCd = OrderInfo.ChildNodes[2].InnerText;
                    medicineHisData1Entity.DataClsf = OrderInfo.ChildNodes[3].InnerText;
                    medicineHisData1Entity.InOutClsf = OrderInfo.ChildNodes[4].InnerText;
                    medicineHisData1Entity.OrderDt = OrderInfo.ChildNodes[5].InnerText;
                    medicineHisData1Entity.OrderDtm = OrderInfo.ChildNodes[6].InnerText;
                    medicineHisData1Entity.OrderNum = OrderInfo.ChildNodes[7].InnerText;
                    medicineHisData1Entity.RoomNum = OrderInfo.ChildNodes[8].InnerText;
                    medicineHisData1Entity.PtntNm = OrderInfo.ChildNodes[9].InnerText;
                    medicineHisData1Entity.PtntNum = OrderInfo.ChildNodes[10].InnerText;
                    medicineHisData1Entity.Sex = OrderInfo.ChildNodes[11].InnerText;
                    medicineHisData1Entity.DoctorNm = OrderInfo.ChildNodes[12].InnerText;
                    medicineHisData1Entity.Birthday = OrderInfo.ChildNodes[13].InnerText;
                    medicineHisData1Entity.PtntAddr = OrderInfo.ChildNodes[14].InnerText;
                    medicineHisData1Entity.PtntTel = OrderInfo.ChildNodes[15].InnerText;                
                    medicineHisData1Entity.flag = 0;
                    bool ifHasHospitalCode = false;
                    for (int i = 0; i < OrderInfo.ChildNodes.Count; i++)
                    {
                        XmlNode MedItem = OrderInfo.ChildNodes[i];
                        if (MedItem.Name == "MedItem")
                        {
                            MedItemEntity medItemEntity = new MedItemEntity();
                            medItemEntity.Uuid = Guid.NewGuid().ToString();
                            medItemEntity.MedCd = MedItem.ChildNodes[0].InnerText;
                            medItemEntity.MedNm = MedItem.ChildNodes[1].InnerText;
                            medItemEntity.MedNote = MedItem.ChildNodes[2].InnerText;
                            medItemEntity.MedSpec = MedItem.ChildNodes[3].InnerText;
                            medItemEntity.MedUnit = MedItem.ChildNodes[4].InnerText;
                            medItemEntity.UseAtcYn = MedItem.ChildNodes[5].InnerText;
                            medItemEntity.OrderInfoId = medicineHisData1Entity.Uuid;
                            MedItemList.Add(medItemEntity);

                            for(int j=0;j< MedItem.ChildNodes.Count; j++)
                            {
                                XmlNode MedItemDose = MedItem.ChildNodes[j];
                                if (MedItemDose.Name == "MedItemDose")
                                {
                                    MedItemDoseEntity medItemDoseEntity = new MedItemDoseEntity();
                                    medItemDoseEntity.Uuid = Guid.NewGuid().ToString();
                                    medItemDoseEntity.DoseList = MedItemDose.ChildNodes[0].InnerText;
                                    medItemDoseEntity.TakeDays = MedItemDose.ChildNodes[1].InnerText;
                                    medItemDoseEntity.TakeDt = MedItemDose.ChildNodes[2].InnerText;
                                    medItemDoseEntity.DrtsCd = MedItemDose.ChildNodes[3].InnerText;
                                    medItemDoseEntity.MedItemId = medItemEntity.Uuid;
                                    MedItemDoseList.Add(medItemDoseEntity);

                                }

                            }

                        }
                        if (MedItem.Name == "HospitalCode")
                        {
                            ifHasHospitalCode = true;
                        }
                    }
                    if (ifHasHospitalCode)
                    {
                        medicineHisData1Entity.HospitalCode = OrderInfo.ChildNodes[16].InnerText;
                    }
                    else
                    {
                        medicineHisData1Entity.HospitalCode = "000";
                    }
                    OrderInfoEntityList.Add(medicineHisData1Entity);

                }

  • 相关阅读:
    MySQL---表的增删改查(基础)
    leetcode刷题日志-13整数转罗马数字
    第四章 网络层
    如何用IDEA创建SpringBoot项目
    Python之第八章 模块和包 --- 模块
    百趣代谢组学资讯:@熬夜的年轻人代谢紊乱急救包-喝普洱茶!
    【MAPBOX基础功能】20、mapbox获取当前已上图的所有的图层
    OblivSketch: Oblivious Network Measurement as a Cloud Service
    脉冲神经网络原理及应用,脉冲神经网络编码方式
    华为欧拉 EulerOS V2.0 SP5 一键安装 Oracle 19C 单机
  • 原文地址:https://blog.csdn.net/weixin_46256404/article/details/132831391