给自己的眼睛放放假
2009-02-05 10:09
197 查看
又回到了那个相当无聊的保守项目中!还是做中文化,两千多条资源,两天内由日文翻译成中文。我一直纳闷的时公司有专业翻译,为什么却还非得拿到项目组中来让我们这些50音图都读不全的人“翻译”?是不是怕我们闲着会头痛?呵呵。
不说废话了。其实已经有了一份上个版本的中文资源文件,这次只是增加了一部分新的条目而已。问题是原来的资源文件只有xml版本的,而要把它放到Excel中对应的位置去只能手动,负值,查找,粘贴。两千多条虽然不算太多,但操作起来还是比较费时间的。于是准备写个小的工具自动将xml文件中的资源匹配并填充到Excel文件中。很久没写代码了,几行代码写了我一两个小时。。。
xml文件结构
private void button1_Click(object sender, EventArgs e)
private static Dictionary<string, string> GetXMLValue(string xmlPath)
{
XPathNavigator nav;
XPathDocument docNav;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
docNav = new XPathDocument(xmlPath);
nav = docNav.CreateNavigator();
nav.MoveToRoot();
//Move to the first child node (comment field).
nav.MoveToFirstChild();
do
{
//Find the first element.
if (nav.NodeType == XPathNodeType.Element)
{
//Determine whether children exist.
if (nav.HasChildren == true)
{
//Move to the first child.
nav.MoveToFirstChild();
//Loop through all of the children.
do
{
//Display the data.
string value = nav.Value;
nav.MoveToFirstAttribute();
string name = nav.Value;
if (!dictionary.ContainsKey(name))
{
dictionary.Add(name, value);
}
nav.MoveToParent();
} while (nav.MoveToNext());
}
}
} while (nav.MoveToNext());
return dictionary;
}
写的有点乱,记录一下,以后有类似需求时修改下就可以继续使用了。毕竟这个破烂保守项目经常做的就是这种事情
不说废话了。其实已经有了一份上个版本的中文资源文件,这次只是增加了一部分新的条目而已。问题是原来的资源文件只有xml版本的,而要把它放到Excel中对应的位置去只能手动,负值,查找,粘贴。两千多条虽然不算太多,但操作起来还是比较费时间的。于是准备写个小的工具自动将xml文件中的资源匹配并填充到Excel文件中。很久没写代码了,几行代码写了我一两个小时。。。
xml文件结构
private void button1_Click(object sender, EventArgs e)
private static Dictionary<string, string> GetXMLValue(string xmlPath)
{
XPathNavigator nav;
XPathDocument docNav;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
docNav = new XPathDocument(xmlPath);
nav = docNav.CreateNavigator();
nav.MoveToRoot();
//Move to the first child node (comment field).
nav.MoveToFirstChild();
do
{
//Find the first element.
if (nav.NodeType == XPathNodeType.Element)
{
//Determine whether children exist.
if (nav.HasChildren == true)
{
//Move to the first child.
nav.MoveToFirstChild();
//Loop through all of the children.
do
{
//Display the data.
string value = nav.Value;
nav.MoveToFirstAttribute();
string name = nav.Value;
if (!dictionary.ContainsKey(name))
{
dictionary.Add(name, value);
}
nav.MoveToParent();
} while (nav.MoveToNext());
}
}
} while (nav.MoveToNext());
return dictionary;
}
写的有点乱,记录一下,以后有类似需求时修改下就可以继续使用了。毕竟这个破烂保守项目经常做的就是这种事情
相关文章推荐
- 各种vssettings让自己的眼睛休息休息
- 各位程序员们一定要好好保护自己的眼睛啊
- 擦亮自己的眼睛去看SQLServer之整体介绍
- eclipse color themes 代码模版,让程序员保护自己的眼睛
- 程序员如何保护自己的眼睛(推荐)
- 擦亮自己的眼睛去看SQLServer之谈谈锁机制
- 程序员如何爱护自己的眼睛
- 2008年8月12号,晴,热。实验室放假的第五天。我现在丈人家,每天都是利用早上的时间写昨天的日记,每写一次,我都知道自己的假期少一天,心里或多或少都有些失落
- 擦亮自己的眼睛去看SQLServer之简单Insert(转)
- 开发者要懂得保护自己眼睛
- 擦亮自己的眼睛去看SQLServer之简单Insert
- 保护自己的眼睛
- 几种码农使用的等宽字体比较——让自己的眼睛爽起来!
- 擦亮自己的眼睛去看SQLServer之谈谈锁机制
- 【转】擦亮自己的眼睛去看SQLServer之整体介绍
- 放假安排 自己MARK
- 如何爱护自己的眼睛
- 擦亮自己的眼睛去看SQLServer之说说跟踪
- 程序员如何保护自己的眼睛
- 自己写出控制VR眼睛人物行走的代码