In VB, to work with the DOM, you'll need to enter the following code:
Dim DOM as XPathNavigator = MainDatasource.CreateNavigator()
To reference a node, you'll need to copy the XPath from the node's data source and paste it into code:
Dim field1 as XPathNavigator = DOM.SelectSingleNode("xpath", NamespaceManager)
Look up MSDN's help with using the InfoPath 2007 Object Model