Sunday 23 October 2011

Add Child to an XML file

This FG shows a simple example of adding a child to an XML file. If the xml file doesn't exist yet, it will create a new file; otherwise it will open the file and update. (I just use an UpDownCounter to make up the value for each child). Please notice that if you want to add 3 new children and make it look like:
<root>
<child>1</child>
<child>2</child>
<child>3</child>
</root>

rather than
<root>
<child>3</child>
</root>

you need to open the existing xml file and add child in, not creating new file every time.


The xml file looks like this after 6 updates:

No comments:

Post a Comment