Get element name from attribute field

J

Jay W

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
 
G

Georg Begerow

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
 
J

Jay W

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top