Write some code. No, first think about how your code has to work, then write some code. You're going to look for top level nodes, create them, look for the children of those nodes, create those, etc. When you've written actual code, when you've tried to do your own work, the code you post here, if you need to, will tell us the things we need to know in order to try to help you.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.