Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace SampleResourceImport
- {
- class Program
- {
- static void Main(string[] args)
- {
- XmlDocument doc = new XmlDocument();
- string filePath = @"[file path to your resx file]";
- doc.Load(filePath);
- XmlElement root = doc.DocumentElement;
- XmlElement datum = null;
- XmlElement value = null;
- XmlAttribute datumName = null;
- XmlAttribute datumSpace = doc.CreateAttribute("xml:space");
- datumSpace.Value = "preserve";
- // The following mocks the actual retrieval of your localized text
- // from a CSV or ?? document...
- // CSV parsers are common enough that it shouldn't be too difficult
- // to find one if that's the direction you go.
- Dictionary<string, string> d = new Dictionary<string, string>();
- d.Add("Label1", "First Name");
- d.Add("Label2", "Last Name");
- d.Add("Label3", "Date of Birth");
- foreach (KeyValuePair<string, string> pair in d)
- {
- datum = doc.CreateElement("data");
- datumName = doc.CreateAttribute("name");
- datumName.Value = pair.Key;
- value = doc.CreateElement("value");
- value.InnerText = pair.Value;
- datum.Attributes.Append(datumName);
- datum.Attributes.Append(datumSpace);
- datum.AppendChild(value);
- root.AppendChild(datum);
- }
- doc.Save(filePath);
- }
- }
- }
Add Comment
Please, Sign In to add comment