码迷,mamicode.com
首页 > 其他好文 > 详细

解析xml

时间:2014-11-10 11:22:44      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   io   color   ar   sp   for   div   

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

 

解析xml

标签:des   style   blog   io   color   ar   sp   for   div   

原文地址:http://www.cnblogs.com/ysf123/p/4086422.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!