I have an InfoPath form and I am using VB .Net for event handling. In the
myFields_OnAfterChange event I am checking the event I need to determine the
node that changed. I was happily doing this using e.Parent.nodeName but the
form schema was changed so that there are text boxes that are bound to
reference attributes. When one of these fields is changed, e.Parent.nodeName
returns the attribute field but I need the name of the actual node element
the attribute belongs to. I tried e.Parent.parentNode.nodeName but aparently
parentNode has a value of 'Nothing'. If anyone has any ideas on getting a
reference to the actual node element I would greatly appreciate it.
Thanks,
Jay
Georg Begerow - 09 Sep 2005 19:09 GMT
Hi Jay,
you can use a selectSingleNode with the ancestor axis of XPath. If the
attribute you are listening for is in the element my:employee you can select
the element with
Dim employee as IXMLDomNode
employee = e.Site.selectSingleNode( "ancestor::my:employee" )
(Don't hit if there is a syntax flaw, I am a C# Guy)
Hope this helps,
Georg
> I have an InfoPath form and I am using VB .Net for event handling. In the
> myFields_OnAfterChange event I am checking the event I need to determine the
[quoted text clipped - 9 lines]
>
> Jay
Jay W - 09 Sep 2005 20:14 GMT
The problem is, I know the name of that attribute but I am trying to
determine the name of the element it belongs it. There a multiple elements
with the same attribute and I need to know on which element the change to the
attribute occured. For example, if I have XML like the following:
<my:Expense my:MonthId="3">500</my:Expense>
<my:Revenue my:MonthId="3">600</my:Revenue>
In the event handler I can see that my:MonthId was changed but I need to
determine if it was changed for the my:Expense element or the my:Revenue
element.
> Hi Jay,
>
[quoted text clipped - 23 lines]
> >
> > Jay
Greg Collins [InfoPath MVP] - 09 Sep 2005 19:53 GMT
Attributes don't have a valid parentNode property. You can use selectSingleNode("..") to get to the node containing the attribute.

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
I have an InfoPath form and I am using VB .Net for event handling. In the
myFields_OnAfterChange event I am checking the event I need to determine the
node that changed. I was happily doing this using e.Parent.nodeName but the
form schema was changed so that there are text boxes that are bound to
reference attributes. When one of these fields is changed, e.Parent.nodeName
returns the attribute field but I need the name of the actual node element
the attribute belongs to. I tried e.Parent.parentNode.nodeName but aparently
parentNode has a value of 'Nothing'. If anyone has any ideas on getting a
reference to the actual node element I would greatly appreciate it.
Thanks,
Jay