zoukankan      html  css  js  c++  java
  • 解析xml

    using System;
    using System.Xml;
    /*CreateDate:2013-06-01 11:06*/
    /*DesignBy:momo QQ:261754265*/
    namespace NCHelper
    {
        /// <summary>
        ///OrderHelper 的摘要说明
        /// </summary>
        public static class ResultHelper
        {
    
            /// <summary>
            /// 返回银企互联付款节点状态
            /// </summary>
            /// <param name="status"> </param>
            /// <param name="xml"></param>
            /// <returns></returns>
            public static string CheckYqReceiveXml(string status, string xml)
            {
                string returnSta = string.Empty;
                try
                {
                    var xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(xml);
                    XmlNodeList xnl = xmlDoc.SelectNodes("CMS/eb/out/rd");
    
                    if (xnl != null)
                        foreach (XmlNode linkNode in xnl)
                        {
                            var xe = (XmlElement) linkNode; //将子节点类型转换为XmlElement类型
                            XmlNode selectSingleNode = xe.SelectSingleNode(status);
                            if (selectSingleNode != null) returnSta = selectSingleNode.InnerText.Trim();
                        }
                }
                catch (Exception ex)
                {
                    
    
                }
    
                return returnSta;
            }
    
            /// <summary>
            /// 返回处理结果消息
            /// </summary>
            /// <param name="status"></param>
            /// <param name="xml"></param>
            /// <returns></returns>
            public static string CheckYqRetMsgXml(string status, string xml)
            {
                string returnSta = string.Empty;
                try
                {
                    var xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(xml);
                    XmlNodeList xnl = xmlDoc.SelectNodes("CMS/eb/pub");
                    XmlNodeList xnl1 = xmlDoc.SelectNodes("CMS/eb/out/rd");
                    if (xnl != null)
                        foreach (XmlNode linkNode in xnl)
                        {
                            var xe = (XmlElement) linkNode; //将子节点类型转换为XmlElement类型
                            XmlNode selectSingleNode = xe.SelectSingleNode(status);
                            if (selectSingleNode != null) returnSta = selectSingleNode.InnerText.Trim();
                        }
                    if (xnl1 != null)
                        foreach (XmlNode linkNode in xnl1)
                        {
                            var xe = (XmlElement)linkNode; //将子节点类型转换为XmlElement类型
                            XmlNode selectSingleNode = xe.SelectSingleNode("iRetMsg");
                            if (selectSingleNode != null) returnSta = selectSingleNode.InnerText.Trim();
                        }
                }
                catch (Exception)
                {
    
                    returnSta = xml;
                }
    
                return returnSta;
            }
        }
    }
  • 相关阅读:
    python 读写json文件(dump, load),以及对json格式的数据处理(dumps, loads)
    Postman + newman + jenkins 的API自动化测试应用
    Selenium + WebDriver 各浏览器驱动下载地址
    pythonon ddt数据驱动二(json, yaml 驱动)
    python ddt 实现数据驱动一
    Python + logging 输出到屏幕,将log日志写入文件
    python 多线程小练习
    pycharm + git 的集成使用
    Map的遍历方式
    69道Spring面试题和答案
  • 原文地址:https://www.cnblogs.com/ysf123/p/4086422.html
Copyright © 2011-2022 走看看