(原创)XML读取方法

public string bmxmltest(string id)
        {
            string name = "";
            XmlNodeList xnl = xmlDoc.DocumentElement.ChildNodes;
            foreach (XmlNode xn in xnl)
            {
                for (int i = 0; i < xn.Attributes.Count; i++)
                {
                    XmlAttribute xa = xn.Attributes[i];
                    if (xa.Name == "id" && xa. == "zyf")
                    {
                        name = xn.InnerText;
                    }
                }
            }
            return name;
        }

---------------------------------------

        public string bmtest(string type)
        {
            string className = "";
            XmlNodeList xnl = xmlDoc.DocumentElement.ChildNodes;
            foreach(XmlNode xn in xnl)
            {
                if (xn.FirstChild.InnerText == type)
                {
                    className = xn.ChildNodes[1].InnerText;
                }
            }
            return className;
        }

posted @ 2007-07-18 20:35  玉米疯收  阅读(301)  评论(0编辑  收藏  举报