读取xml并将其写入resource.resx中
本文关键字:resource resx xml 读取 | 更新日期: 2023-09-27 18:21:15
Am尝试将xml绑定到resource.resx以完成全局化
这是我的代码,
System.Xml.XmlTextReader reader = new XmlTextReader("..//Swedish.xml");
ResXResourceWriter writer = new ResXResourceWriter("..//App_GlobalResources/Resource.sv-SE.resx");
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "string")
writer.AddResource(reader.GetAttribute("name"), reader.ReadString());
}
writer.Generate();
writer.Close();
我的xml是
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<string name="Account"> konto </string>
<string name="AccountDetails">Kontouppgifter</string>
<string name="CompanyManagement">Företagsledning</string>
<string name="Logout">Logga ut</string>
</resources>
现在我的问题是,只有当我设置了整个路径时,我才能获得xml伙计们能帮我吗
我也试过,
System.Xml.XmlTextReader reader = new XmlTextReader("~/Swedish.xml");
System.Xml.XmlTextReader reader = new XmlTextReader(@"/Swedish.xml");
我的问题是当我更改代码时清除了一些
string xmlPath = Server.MapPath("~/XMLFile1.xml");
string resourcePath = Server.MapPath("~/LocalResource/Resource.sv-SE.resx");
System.Xml.XmlTextReader reader = new XmlTextReader(xmlPath);
ResXResourceWriter writer = new ResXResourceWriter(resourcePath);
但是出现了一些运行时错误