Reputation: 5512
I have an XML as below
<ROOT>
<Device>
<host>localhost</host>
<Port>52000</Port>
</Device>
<DeviceHost>
<Server>Server.exe</Server>
<Port>81</Port>
</DeviceHost>
<Settings>
<Flag1>100</Flag1>
<Flag2>2000</Flag2>
</Settings>
</ROOT>
How can I update the Flag1
and Flag2
to 200
and 4000
respectively without changing other values using VC++?
I have two function wrote using api MSXML.
doc.LoadXml(Data);//for loading the xml data
doc.Save(FilePath);//for saving the xml data
But my issue is before saving how can i update two node values
Upvotes: 0
Views: 1384
Reputation: 5132
You would need to get the correct node by calling getElementsByTagName
(which should return a NodeList containing one item) and then call put_nodeValue
to write the value -- there are some MSDN samples here and here
EDIT: you should also be able to use doc.selectSingleNode("/ROOT/Flag1", &pNode)
as per this MSDN article
Upvotes: 1