C # 读取XML文件

2016-04-05  本文已影响28人  BlackNeko

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;
        }
上一篇下一篇

猜你喜欢

热点阅读