c# – 如何读取XML以创建resx文件
作者:互联网
我有一个XML文件
<? xml version="1.0" encoding="utf-8"?>
<resources>
<string name="Foo">Bar</string>
<string name="Foo1">Bar1</string>
// More string Tags here
</resources>
我试过了
XMLTextReader reader = new XmlTextReader("FooBar.xml");
ResXResourceWriter writer = new ResXResourceWriter("FooBar.resx");
while(reader.Read())
{
if(reader.NodeType == XmlNodeType.Element && reader["name"] != null)
writer.AddResource("What_should_I_write_here", "What_should_I_write_here");
}
如何阅读这个xml,以便我可以创建一个resx文件.
解决方法:
我终于做到了
XMLTextReader reader = new XmlTextReader("FooBar.xml");
ResXResourceWriter writer = new ResXResourceWriter("FooBar.resx");
while(reader.Read())
{
if(reader.NodeType == XmlNodeType.Element && reader.Name == "string")
writer.AddResource(reader.GetAttribute("name"), reader.ReadString());
}
writer.Generate();
writer.Close();
标签:c,net,xml,resx 来源: https://codeday.me/bug/20190613/1232306.html