parentNode doesn't work! - InfoPath Dev
in

InfoPath Dev

parentNode doesn't work!

Last post 10-11-2005 10:27 AM by vt_asparagus. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 10-10-2005 09:27 AM

    parentNode doesn't work!

    Hi everybody.
    I'm a new entry in this forum that has been very helpful for me learning infopath.
    I hope that someone could help me with a problem that I can't solve.

    I have an xml structured in this way:

    <FATHER>
    <ID>1</ID>
    <..>..</..>
    <CHILD>
    <ID>1.1</ID>
    <..>..<..>
    </CHILD>
    </FATHER>

    I have a repeating section for the child where I can add/erese elements.
    When I delete a child section I need to know the ID of the father to change the value of another TAG.

    In the event Child::OnBeforeChange I wrote a code like this

    XDocument.UI.Alert(eventObj.Site.parentNode.selectSingleNode("ID").value;

    OR

    XDocument.UI.Alert(eventObj.Site.selectSingleNode("../ID").value;

    The problem is that both work when I insert or I update a child element but not when I delete. In this case It gives me an error like "Object needed".

    The strange thing is that during delete I can just access to the child elements(for example eventObj.Site.selectSingleNode("ID") but not to the father.

    Anybody can help me???
    Thanks a lot.

    Matteo.
    PS: sorry for my english! :-)






  • 10-10-2005 09:44 AM In reply to

    Re: parentNode doesn't work!

    Hi,

    Have you tried to play with eventObj.Source rather than Site?

    Regards,

    Franck Dauché
  • 10-11-2005 12:24 AM In reply to

    Re: parentNode doesn't work!

    I tried. But it gives me the same problem.


    quote:
    Originally posted by franck

    Hi,

    Have you tried to play with eventObj.Source rather than Site?

    Regards,

    Franck Dauché

  • 10-11-2005 10:27 AM In reply to

    Re: parentNode doesn't work!

    The eventObj.Site does NOT return the entire XML Document for the form. For instance, if you drop this code into your OnBeforeChange event, review what will be returned.

    XDocument.UI.Alert(eventObj.Site.xml)

    It would return something like:

    <CHILD>
    <ID>1.1</ID>
    <..>..<..>
    </CHILD>

    The father will not be returned in eventObj.Site. To get the father node for the child beind deleted, you will need to write an XPath statement against XDocument.DOM.selectSingleNode(...) to get the father.
    Jason
    http://www.k2distillery.com/
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.