美文网首页
C # 读取XML文件

C # 读取XML文件

作者: BlackNeko | 来源:发表于2016-04-05 17:34 被阅读28次

    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;
            }
    

    相关文章

      网友评论

          本文标题:C # 读取XML文件

          本文链接:https://www.haomeiwen.com/subject/mimplttx.html