I have the following XML structure so that I can add my configuration details to lastconnected element:
<?xml version="1.0" encoding="utf-8" ?>
<lastconnectedServers>
</lastconnectedServers >
Now I want to do some XML operation like adding elements and attributes.For Example I want to add the elements to xml above:(Inside elemet lastconnectedServers):
<Server ip="" domain="">
<SharedFolder name="" type=""/>
<SharedFolder name="" type =""/>
<SharedFolder name="" type =""/>
</Server>
so that the resulting XML will look something like below:
<?xml version="1.0" encoding="utf-8" ?>
<lastconnectedServers>
<Server ip="" domain="">
<SharedFolder name="" type=""/>
<SharedFolder name="" type =""/>
<SharedFolder name="" type =""/>
</Server>
</lastconnectedServers >
Here is the sample code using MSXML. COM error checking is omitted. for The code looks a little bit wordy because of ATL helpers for COM usage, but the programming model follows W3C DOM APIs which is quite well accepted by xml developers.
Hope this helps.