unity3d读写XML

来源:互联网 发布:下载billboard软件 编辑:程序博客网 时间:2024/05/22 08:28
string ReadVersion()   //从本地配置文件中读取版本信息
{
WebClient wc = new WebClient();
XmlDocument doc = new XmlDocument();
#if UNITY_ANDROID
string path = GetFilePath("","1")+"/version.xml";
#else
string path = GetFilePath("","0")+"/version.xml";
#endif
if(File.Exists(path))
{
doc.Load(path);
wc = null;
return doc.SelectSingleNode("version").InnerText;
}
return "";
}
void WriteVersion(string version) //修改本地配置文件中的版本信息
{
WebClient wc = new WebClient();
XmlDocument doc = new XmlDocument();
#if UNITY_ANDROID
string path = GetFilePath("","1")+"/version.xml";
#else
string path = GetFilePath("","0")+"/version.xml";
#endif
if(File.Exists(path))
{
doc.Load(path);
XmlNode node = doc.SelectSingleNode("version");
XmlText text = doc.CreateTextNode(version);
node.AppendChild(text); //node.innerText = version
doc.Save(path);
}
wc = null;
}
0 0