Link to home
Start Free TrialLog in
Avatar of silentthread2k
silentthread2kFlag for United States of America

asked on

How can I modify an xml value based on the attribute value.

It does not look like its as easy as selectsinglenode. I could be wrong though.
Example....

XmlDocument xmldoc = new XmlDocument();
xmldoc.Load("myfile.xml");            

From......                  
                        
<root>
    <properties>
        <property name="index1">myvalue1</property>
        <property name="index2">myvalue2</property>
        <property name="index3">myvalue3</property>
      </properties>
</root>


To.... (notice index2 value has changed)

<root>
    <properties>
        <property name="index1">myvalue1</property>
        <property name="index2">myvalue2-MODIFIED</property>
        <property name="index3">myvalue3</property>
      </properties>
</root>
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,
You can also do it with InnerXml property also.
node.InnerXml= node.InnerXml+ "-MODIFIED";
Avatar of silentthread2k

ASKER

:-)