Sure thing...samples in JScript and VB.NET included below.
JScript (taken from http://msdn.microsoft.com/en-us/library/aa662354%28office.11%29.aspx):
function XDocument::OnVersionUpgrade(eventObj)
{
if (!XDocument.DOM.selectSingleNode("/Customers/CustomerInfo/EmailAddress"))
{
try
{
// Create the new element.
var objItemNode = XDocument.DOM.selectSingleNode("/Customers/CustomerInfo")
.ownerDocument.createElement("EmailAddress");
// Add the new <item> element to the XML document as a
// child of the <order> element.
XDocument.DOM.selectSingleNode("/Customers/CustomerInfo")
.appendChild(objItemNode);
eventObj.ReturnStatus=true;
}
catch(ex)
{
XDocument.UI.Alert("There was an error inserting the " +
"<EmailAddress> node.\nDescription: " + ex.description);
eventObj.ReturnStatus=false;
}
}
}
VB.NET (InfoPath 2007):
Public Sub FormEvents_VersionUpgrade(ByVal sender As Object, ByVal e As VersionUpgradeEventArgs)
Dim xMain As XPathNavigator = MainDataSource.CreateNavigator()
Dim clientTitlePath As XPathNavigator
clientTitlePath = xMain.SelectSingleNode("/FormData/ClientInfo/ClientTitle", NamespaceManager)
If clientTitlePath Is DBNull.Value Or clientTitlePath Is Nothing Then
xMain.SelectSingleNode("/FormData/ClientInfo", NamespaceManager).AppendChild("<ClientTitle/>")
End If
End Sub