积极答复者
xml更新问题

问题
答案
-
大侠你好!
<Menu> <MenuItem> <ID>1</ID> <DescriptionFilePath></DescriptionFilePath> </em></strong> </MenuItem> <MenuItem> <ID>2</ID> <DescriptionFilePath>..\Resource\系统管理.rtf</DescriptionFilePath> </MenuItem> <MenuItem> <ID>3</ID> <DescriptionFilePath>..\Resource\标准时间制定.rtf</DescriptionFilePath> </MenuItem> <MenuItem> <ID>4</ID> <DescriptionFilePath>..\Resource\工时资料管理.rtf</DescriptionFilePath> </MenuItem> <MenuItem> <ID>5</ID> <DescriptionFilePath>..\Resource\帮助.rtf</DescriptionFilePath> </MenuItem> </Menu>
上面是我的xml文件, 我本意是在DescriptionFilePath中加入"..\\Resource\\Welcome.rtf",然后按照你给的方法
XmlDocument doc = new XmlDocument();
doc.Load("MenuConfig.xml");
doc.SelectSingleNode("/MenuItem/DescriptionFilePath").InnerText = "..\\Resource\\Welcome.rtf";
doc.Save("MenuConfig.xml");最后结果
秦臻XmlDocument doc = new XmlDocument();
doc.Load("xxx.xml");
XName n = doc.SelectSingleNode("/Menu/MenuItem/DescriptionFilePath");
if(String.IsNullOrEmpty(n.InnerText))
{
n.InnerText = "Your value";
}doc.Save("C:\\try.xml");
如果你有其它意见或私下交流,请直接发送maledong_work@foxmail.com;或者
If you do not have QQ, please open the page and download it and click the image to talk or leave message for me.
下载MSDN桌面工具(Vista,Win7)
下载Technet桌面小工具(Vista,Win7)
慈善点击,点击此处- 已编辑 ThankfulHeartModerator 2011年9月20日 8:33
- 已标记为答案 秦臻 2011年9月21日 9:36
全部回复
-
求助:
我用c#编程,用到xml文件,后来我发现需要修改xkl文件,然后我就直接在xml中修改,但是这种修改并没有反应到界面上,我一步一步运行,发现我这种修改一点作用都没有,我想问问是怎么回事?应该如何操作才能够实现更新。
秦臻
请确定你在修改xml文件之后有没有保存,并且重新加载绑定到界面上?
如果你有其它意见或私下交流,请直接发送maledong_work@foxmail.com;或者
If you do not have QQ, please open the page and download it and click the image to talk or leave message for me.
下载MSDN桌面工具(Vista,Win7)
下载Technet桌面小工具(Vista,Win7)
慈善点击,点击此处 -
求助2:
还有我把这个xml文件直接删除,但是运行,发现依然能显示这个xml文件里面的数据,我真的不明白啦!
秦臻
有没有用缓存或者什么?请上传你的工程项目截图,并且说明你要实现什么功能?谢谢
如果你有其它意见或私下交流,请直接发送maledong_work@foxmail.com;或者
If you do not have QQ, please open the page and download it and click the image to talk or leave message for me.
下载MSDN桌面工具(Vista,Win7)
下载Technet桌面小工具(Vista,Win7)
慈善点击,点击此处 -
原来是
<MenuItem>
<ID>1</ID>
<DescriptionFilePath></DescriptionFilePath>
</MenuItem>现在我想改为
<MenuItem>
<ID>1</ID>
<DescriptionFilePath>..\Resource\Welcome.rtf</DescriptionFilePath>
</MenuItem>即加了一个路径,以方便打开Welcome.rtf文件。我仅仅在xml文件中做了修改,不懂得绑定缓存之类的,希望大侠帮我。
附图是我新建一个项目,重做一边的结果。如果按照我上面的修改,右下角为空白一片
秦臻 -
原来是
<MenuItem>
<ID>1</ID>
<DescriptionFilePath></DescriptionFilePath>
</MenuItem>现在我想改为
<MenuItem>
<ID>1</ID>
<DescriptionFilePath>..\Resource\Welcome.rtf</DescriptionFilePath>
</MenuItem>即加了一个路径,以方便打开Welcome.rtf文件。我仅仅在xml文件中做了修改,不懂得绑定缓存之类的,希望大侠帮我。
附图是我新建一个项目,重做一边的结果。如果按照我上面的修改,右下角为空白一片
秦臻
你的图是怎么生成的?和xml有什么关系。还有,你的DescriptionFilePath(相对路径)确定对哇?
如果你有其它意见或私下交流,请直接发送maledong_work@foxmail.com;或者
If you do not have QQ, please open the page and download it and click the image to talk or leave message for me.
下载MSDN桌面工具(Vista,Win7)
下载Technet桌面小工具(Vista,Win7)
慈善点击,点击此处 -
路径当然是对的,因为我的xml文件里面有几个路径,其他的都能用,只有这一个不能用。右下角是一个panel,图的显示是打开一个rtf文件。而xml的作用就是提供这些rtf文件的路径。我知道我直接在xml文件中修改是不够的,我只是想知道我在文件里修改后再如何操作才能使得绑定之类的,即实时更新
秦臻
那你是如何把xml一开始显示到页面上的呢?
如果你有其它意见或私下交流,请直接发送maledong_work@foxmail.com;或者
If you do not have QQ, please open the page and download it and click the image to talk or leave message for me.
下载MSDN桌面工具(Vista,Win7)
下载Technet桌面小工具(Vista,Win7)
慈善点击,点击此处 -
谢谢您一直回答我的问题。但是我感觉你回答的并不是我要问的问题;我没有显示xml,我只是load(xml),然后提取里面的路径,然后用richtextbox打开这个路径而已。我只是想如何更新那个xml文件,我在网上只找到了用语言更新,我只是想在xml文件中直接更新罢了。既然这样不好使,我还是用语言更新吧
秦臻
可以啊,给建议:XmlDocument doc = new XmlDocument();
doc.Load("xxx.xml");
doc.SelectSingleNode("/MenuItem/DescriptionFilePath").InnerText = "Your new value";
doc.Save("C:\\try.xml");
如果你有其它意见或私下交流,请直接发送maledong_work@foxmail.com;或者
If you do not have QQ, please open the page and download it and click the image to talk or leave message for me.
下载MSDN桌面工具(Vista,Win7)
下载Technet桌面小工具(Vista,Win7)
慈善点击,点击此处 -
大侠你好!
<Menu> <MenuItem> <ID>1</ID> <strong><em> <DescriptionFilePath></DescriptionFilePath> </em></strong> </MenuItem> <MenuItem> <ID>2</ID> <DescriptionFilePath>..\Resource\系统管理.rtf</DescriptionFilePath> </MenuItem> <MenuItem> <ID>3</ID> <DescriptionFilePath>..\Resource\标准时间制定.rtf</DescriptionFilePath> </MenuItem> <MenuItem> <ID>4</ID> <DescriptionFilePath>..\Resource\工时资料管理.rtf</DescriptionFilePath> </MenuItem> <MenuItem> <ID>5</ID> <DescriptionFilePath>..\Resource\帮助.rtf</DescriptionFilePath> </MenuItem> </Menu>
上面是我的xml文件, 我本意是在DescriptionFilePath中加入"..\\Resource\\Welcome.rtf",然后按照你给的方法
XmlDocument doc = new XmlDocument();
doc.Load("MenuConfig.xml");
doc.SelectSingleNode("/MenuItem/DescriptionFilePath").InnerText = "..\\Resource\\Welcome.rtf";
doc.Save("MenuConfig.xml");最后结果
秦臻 -
大侠你好!
<Menu> <MenuItem> <ID>1</ID> <DescriptionFilePath></DescriptionFilePath> </em></strong> </MenuItem> <MenuItem> <ID>2</ID> <DescriptionFilePath>..\Resource\系统管理.rtf</DescriptionFilePath> </MenuItem> <MenuItem> <ID>3</ID> <DescriptionFilePath>..\Resource\标准时间制定.rtf</DescriptionFilePath> </MenuItem> <MenuItem> <ID>4</ID> <DescriptionFilePath>..\Resource\工时资料管理.rtf</DescriptionFilePath> </MenuItem> <MenuItem> <ID>5</ID> <DescriptionFilePath>..\Resource\帮助.rtf</DescriptionFilePath> </MenuItem> </Menu>
上面是我的xml文件, 我本意是在DescriptionFilePath中加入"..\\Resource\\Welcome.rtf",然后按照你给的方法
XmlDocument doc = new XmlDocument();
doc.Load("MenuConfig.xml");
doc.SelectSingleNode("/MenuItem/DescriptionFilePath").InnerText = "..\\Resource\\Welcome.rtf";
doc.Save("MenuConfig.xml");最后结果
秦臻XmlDocument doc = new XmlDocument();
doc.Load("xxx.xml");
XName n = doc.SelectSingleNode("/Menu/MenuItem/DescriptionFilePath");
if(String.IsNullOrEmpty(n.InnerText))
{
n.InnerText = "Your value";
}doc.Save("C:\\try.xml");
如果你有其它意见或私下交流,请直接发送maledong_work@foxmail.com;或者
If you do not have QQ, please open the page and download it and click the image to talk or leave message for me.
下载MSDN桌面工具(Vista,Win7)
下载Technet桌面小工具(Vista,Win7)
慈善点击,点击此处- 已编辑 ThankfulHeartModerator 2011年9月20日 8:33
- 已标记为答案 秦臻 2011年9月21日 9:36
-
Hi 秦臻,
欢迎来到MSDN论坛!
您的问题处理得怎么样了?方便的话,请您向我们提供以下信息:
1. 在直接更新XML文件后,你是否重新run了一次项目。
2. 请问根据Wei_Dong最后的回复,您的项目是否有任何进展?
如果还有任何问题,请您尝试单步调试下程序,看看每一步的是不是都跟预期过程一样。
如果您需要任何帮助,请告诉我们。
祝,一切顺利!
Yoyo Jiang[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
Hi 秦臻,
谢谢您的反馈!如果您的问题已经解决了,请您把有用的回复标记为答案。
谢谢您的理解!
祝,今天愉快!
Yoyo Jiang[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.