• C#读取XML格式字符串


     System.Text.StringBuilder res = new System.Text.StringBuilder();
                res.Append(" <?xml version='1.0' encoding='utf-8'?>");
                res.Append("<YG_HCCGFHXX>");
                res.Append("<XMLDATA>");
                res.Append("<HEAD>");
                res.Append("<JSSJ>接收时间</JSSJ>");
                res.Append("<ZTCLJG>消息主体处理结果</ZTCLJG>");
                res.Append("<CWXX>错误提示内容</CWXX>");
                res.Append("<BZXX>备注信息</BZXX>");
                res.Append("</HEAD>");
                res.Append("<MAIN>");
                res.Append("<DDBH>采购单号</DDBH>");
                res.Append("</MAIN>");
                res.Append("<DETAIL>");
                res.Append("<STRUCT>");
                res.Append("<DDMXBH>采购单明细编号</DDMXBH>");
                res.Append("<SXH>顺序号</SXH>");
                res.Append("<HCTBDM>耗材统编代码</HCTBDM>");
                res.Append("<HCXFDM>耗材细分代码</HCXFDM>");
                res.Append("<YYBDDM>医院本地代码</YYBDDM>");
                res.Append("<QYKC>企业库存</QYKC>");
                res.Append("<CLJG>处理结果</CLJG>");
                res.Append("<CLQKMS>处理情况描述</CLQKMS>");
                res.Append("</STRUCT>");
                res.Append("</DETAIL>");
                res.Append("</XMLDATA>");
                res.Append("</YG_HCCGFHXX>");
    
    
    XElement root = XElement.Parse(@"" + res.ToString().Trim() + "");
    
                //采购单号
                string DDBH = root.Element("XMLDATA").Element("MAIN").Element("DDBH").Value;
                //与采购单明细号
                string DDMXBH = root.Element("XMLDATA").Element("DETAIL").Element("STRUCT").Element("DDMXBH").Value;
  • 相关阅读:
    2020软件工程作业06
    2020软件工程作业05
    jdk13.0.2安装完成后,使用binjlink.exe 命令配置jre报错
    软件工程04(已报废)
    2020软件工程作业03
    软件工程问题解决清单
    软件工程作业02
    2020软件工程作业01
    2020软件工程个人作业06——软件工程实践总结作业
    2020软件工程作业05
  • 原文地址:https://www.cnblogs.com/zyx321/p/6491276.html
Copyright © 2020-2023  润新知