C # 读取XML文件


public static Boolean modifyManifest(PTData data, String code)
        {
            Console.WriteLine(TAG + "  code::" + code);

            string mDir = data.ApkPath + Path.DirectorySeparatorChar + "test" + Path.DirectorySeparatorChar
                + "AndroidManifest.xml";
            Console.WriteLine(TAG + " path::" + mDir);
            //读取xml
            XmlDocument doc = new XmlDocument();
            doc.Load(mDir);
            XmlNodeList mtNodeList = doc.SelectNodes("//meta-data");
            foreach (XmlNode node in mtNodeList)
            {
                string name = node.Attributes["android:name"].Value;
                //Console.WriteLine("name::" + name);
                string value = node.Attributes["android:value"].Value;
                //Console.WriteLine("value::" + value);
                if ("AD_CODE".Equals(name) && value != null)
                {
                    node.Attributes["android:value"].Value = code;
                    doc.Save(mDir);
                }
            }
            return false;
        }
posted @ 2016-03-15 21:47  pepelu  阅读(3325)  评论(0编辑  收藏  举报