View Single Post
 
Old 04-30-2006, 01:12 PM
Zainebq Zainebq is offline
Novice
 
Join Date: Apr 2006
Posts: 1
Zainebq
Default Infopath Onversionchange

Hi. I am working on this Infopath template. I made some changes to the original version, and wanted to reversion the template. In the new template I added an xml node to the schema. But now when I try to open the old files, it gives an error because that node cannot be found in the old version.

I was trying to use the onversionchange procedure as given in msdn website. But it is not working. I thought I might need an XPath, but still doesnt seem to work. When I use an XPath, I need to save the new node to the XDocument and it does not seem to work. Can someone please help me regarding this. I will be REALLY thankful!

The code I currently have is as follows:

Sub XDocument_OnVersionUpgrade(eventObj)
if XDocument.DOM.selectsingleNode("/my:myFIelds/my:field3") is Nothing
then

'->following is setting up the xPath. I need to specify the "my" namespace
Dim oDomNewNode
set oDomNewNode = createobject("msxml2.domdocument.5.0")
oDomNewNode.loadXML XDocument.DOM.xml
oDomNewNode.setProperty "SelectionLanguage", "XPath"
oDomNewNode.setProperty "SelectionNamespaces",
"xmlns:my=""http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-04-27T17:55:59"""

Dim objItemNode, objItemAddNode, checkNode
set objItemNode =
oDomNewNode.selectSingleNode("/my:myFields").ownerDocument.createElement("field3" )
set objItemAddNode =
XDocument.DOM.selectsingleNode("/my:myFields").ownerDocument.createElement("field3" )


' Add the new <item> element to the XML document as a
' child of the <order> element.
set checkNode = oDomNewNode.selectSingleNode("/my:myFields").appendChild(objItemNode)
checkNode.text = "this is field3"

'--->Here i was trying to save to the XDocument. But its wrong
'oDomNewNode.save(xDocument.DOM.xml)
end if
end sub
Reply With Quote