xml 文件 深度查找(记)

/// <summary>
/// xml内容深度查找
/// </summary>
/// <param name="nodenames">节点序(从父到子 多个用逗号隔开)</param>
/// <returns></returns>

public static string getNodeContext(string nodenames)
        {
            string[] nodes = nodenames.Split(',');
            string XmlPath = System.Environment.CurrentDirectory + @"\Xmldata.xml.config";
            XmlDocument docXml = new XmlDocument();
            docXml.Load(@XmlPath);

 

            XmlNode xn = docXml.SelectSingleNode("RootNode"); //根节点
            for (int i = 0; i < nodes.Length; i++)
            {
                xn = xn.SelectSingleNode(nodes[i]);
            }
            return xn.InnerXml;
        }

posted on 2010-09-28 14:52  千羽  阅读(260)  评论(0)    收藏  举报

导航