其他分享
首页 > 其他分享> > xml转化为Dictionary

xml转化为Dictionary

作者:互联网

public SortedDictionary<string, object> FromXml(string xml)
    {
        SortedDictionary<string, object> m_values = new SortedDictionary<string, object>();
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.LoadXml(xml);
        XmlNode xmlNode = xmlDoc.FirstChild;//获取到根节点<xml>
        XmlNodeList nodes = xmlNode.ChildNodes;
        foreach (XmlNode xn in nodes)
        {
            XmlElement xe = (XmlElement)xn;
            m_values[xe.Name] = xe.InnerText;//获取xml的键值对到WxPayData内部的数据中
        }
        return m_values;
    }

 

装载:https://www.cnblogs.com/xsj1989/p/9884703.html

标签:xml,xn,Dictionary,SortedDictionary,转化,values,xe,xmlDoc
来源: https://www.cnblogs.com/liuzz/p/15011778.html