您的位置:首页 > 其它

C # 读取XML文件

2016-03-15 21:47 267 查看
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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: