Click here to Skip to main content
15,915,093 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
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"
...


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
Posted

1 solution

This is a bit of an issue.

To change the value from Red to Green 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.
 
Share this answer
 
Comments
symreds 4-Feb-11 3:53am    
Thank you Andrew

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900