调用: ReadXMLByPath(@"C:\Users\PETER\Desktop\芯动心电网络管理系统\FTP数据\e30c180b-2512-4073-ae7a-d65be041f424.XML"); string ReadXMLByPath(string path) { string caseName = ""; string age = ""; string sex = ""; string HR = string.Empty, PR = string.Empty, P = string.Empty, QRS = string.Empty, T = string.Empty, QT = string.Empty, QTc = string.Empty, PAxis = string.Empty, QRSAxis = string.Empty, TAxis = string.Empty, R_V5 = string.Empty, S_V1 = string.Empty; try { XmlDocument doc1 = new XmlDocument(); doc1.Load(path); //获取当前XML文档的根 一级 XmlNode oNode = doc1.DocumentElement; //获取根节点的所有子节点列表 XmlNodeList oList = oNode.ChildNodes; //标记当前节点 XmlNode oCurrentNode; //遍历所有二级节点 for (int i = 0; i < oList.Count; i++) { //二级 oCurrentNode = oList[i]; //检测当前节点的名称,节点的值是否与已知匹配 if (oCurrentNode.Name.Equals("caseinformation")) { //检测是否有子节点 三级 if (oCurrentNode.HasChildNodes) { //遍历当前节点的所有子节点 for (int n = 0; n < oCurrentNode.ChildNodes.Count; n++) { //检测当前节点的子节点名称是否与已知匹配 if (oCurrentNode.ChildNodes[n].Name.ToLower() == "otherparam") { //遍历当前节点的所有子节点 for (int ii = 0; ii < oCurrentNode.ChildNodes[n].ChildNodes.Count; ii++) { if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.ToLower().Equals("caseName")) { caseName = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.ToLower().Equals("sex")) { sex = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.ToLower().Equals("age")) { age = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.ToLower().Equals("age")) { age = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } } } //检测当前节点的子节点名称是否与已知匹配 if (oCurrentNode.ChildNodes[n].Name== "Parameters") { //遍历当前节点的所有子节点 for (int ii = 0; ii < oCurrentNode.ChildNodes[n].ChildNodes.Count; ii++) { if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("HR"))//心率 { HR = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("PRInterval")) { PR = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("PDuration")) { P = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("QRSDuration")) { QRS = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("TDuration")) { T = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("QTInterval")) { QT = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("QTcInterval")) { QTc = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("PAxis")) { PAxis = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("QRSAxis")) { QRSAxis = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("TAxis")) { TAxis = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("R_V5")) { R_V5 = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("S_V1")) { S_V1 = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; } } } } } } } } catch { } return caseName + "," + sex + "," + age; }