This tutorial should have everything you need to get started working with the XPathNavigator in InfoPath 2007. If you're fairly new to coding, you'll first have to learn how to use it to get your string values out of the data source and into variables in your code.
http://msdn.microsoft.com/en-us/library/bb509311.aspx
Once you've done that, you can use the XPathNavigator's Evaluate() function to evaluate your XPath expressions and get a value:
http://msdn.microsoft.com/en-us/library/system.xml.xpath.xpathnavigator.evaluate.aspx