reset dom - InfoPath Dev
in

InfoPath Dev

reset dom

Last post 09-14-2006 11:55 PM by buki79. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 09-07-2006 03:53 AM

    reset dom

    Hi,

    I import an xml file into a form by custom code. Now I wanted to insert a link in the custom task pane which resets the form.
    This peace of code resets the form.

    var nodes = XDocument.DOM.selectNodes("/*");
    while(node = nodes.nextNode())
    node.text=" ";

    But when I wanted to import another xml file I get a nullpointer exception. It seems that this peace of code deletes the whole dom or why can't I import the xml at the second time?

    Regards,

    buki
  • 09-11-2006 10:50 PM In reply to

    Hi Buki,
    My guess is that it's a bug in your custom import code. I'd have to look at that. Sorry for not responding sooner!
    Patrick Halstead
    Project Manager at Qdabra
  • 09-13-2006 03:57 AM In reply to

    Hi,

    I guess my import code works fine. When I import the same xml file once, twice or three times without reseting it just adds the contents to the form. But if I use the reset function, this next time I use the import function I get the error "selectSingleNode(..) Null or no object".
    This is an example of my import code:
    if (gdomImported.selectSingleNode("/NOTIF/NOTIF_PARTNER/item[PARVW_VTEXT/text()='Autor']/PARNR_NAM"))
    {
    objDataDOM.selectSingleNode("/my:ECx/my:BASIC_DATA/my:BD_INITIATOR").text = gdomImported.selectSingleNode("/NOTIF/NOTIF_PARTNER/item[PARVW_VTEXT/text()='Autor']/PARNR_NAM").text;
    }
    if(gdomImported.selectSingleNode("/NOTIF/NOTIF_TEXT/item[1]/TDLINE"))
    {
    objDataDOM.selectSingleNode("/my:ECx/my:BASIC_DATA/my:BD_REASON_CR").text = gdomImported.selectSingleNode("/NOTIF/NOTIF_TEXT/item[1]/TDLINE").text;
    }
    var parent = objDataDOM.selectSingleNode("/my:ECx/my:BASIC_DATA");
    var firstRow = objDataDOM.selectSingleNode("/my:ECx/my:BASIC_DATA/my:BD_CHANGEDESC");
    var i = 2;
    while (gdomImported.selectSingleNode("/NOTIF/NOTIF_TEXT/item["+i+"]/TDLINE"))
    {
    var newRow = firstRow.cloneNode(true);
    newRow.text = gdomImported.selectSingleNode("/NOTIF/NOTIF_TEXT/item["+i+"]/TDLINE").text;
    parent.insertBefore(newRow, firstRow);
    i++;
    }

    This is mainly taken from the CD import example provided by Microsoft.
    But if you have any hints on how to clear a form by script, I'd appreciate that very much.

    Best regards,

    buki
  • 09-14-2006 10:08 AM In reply to

    Hi buki79,

    This is the problem with your reset code. your reset code is making the root node empty. you can use below reset code instead:

    var nodes = XDocument.DOM.selectNodes("//*");
    while(node = nodes.nextNode())
    {
    if(node.selectNodes("child::*").length == 0)
    {
    node.text = "";
    }
    }

  • 09-14-2006 11:55 PM In reply to

    Thanks for your help! That works fine!
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.