更改XML文件中的属性字符串 [英] Change Attribute String in a XML file
本文介绍了更改XML文件中的属性字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我不是用MFC读/写XML文件的专家.我必须在XML文件中更改属性字符串.这是一个示例:
来自
Hi everyone,
I''m not very expert in reading / writing XML files with MFC. I must change an Attribute String in a XML file. Here is an example:
from
- <PropertyDescriptions>
- <PropertyDescription PropertyName="Color" Value="Red" />
-
到
to
...
Value="Green"
...
而不重写整个文件.我使用IXmlReader/IXmlWriter来读取/写入xml文件.有人可以向我解释(甚至带有示例)如何根据给定的属性名称更改单个值(在我的示例中为值")?
非常感谢
without rewrite the entire file. I use IXmlReader/IXmlWriter to read/write xml file. Someone could explain me (even with examples) how to change a single value given its attribute name (in my example "Value")?
Thanks a lot
推荐答案
这有点问题.
要将值从Red
更改为Green
,您实际上是在将数据长度更改2个字节(在Unicode文件中为4个字节).这意味着文件的其余部分将向下移动2个字符,从而需要重写文件的其余部分.您只能避免在更改值之前重写数据.
This is a bit of an issue.
To change the value fromRed
toGreen
you are actually changing the length of the data by 2 bytes (or 4 in a Unicode file). This means that the entire rest of the file is moved down by 2 characters, requiring the rest of the file to be rewritten. You can only avoid rewriting the data before the changed value.
这篇关于更改XML文件中的属性字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文