Clarification: You don't access InfoPath objects (i.e. controls). You access XML DOM nodes. This requires knowing how to write code against the XML DOM. You can use JScript, VBScript, C#.NET or VB.NET for your code.
You use XPath to make selections of particular nodes (elements or attributes). Once you have a particular node, you can read or change its value.