How to Store Trees on Disk
Every XML database will have its own solutions to these problems. You could do worse that explore the source code of an open-source XML database.

The main aspects of any solution will be (a) the ability to navigate from a node to its children or parent by following some kind of pointer structure rather than by parsing raw XML and searching sequentially, (b) the availability of indexes that enable you to find nodes quickly given properties of the node, e.g. indexing elements by name.