Replace a node in another document - InfoPath Dev
in

InfoPath Dev

Replace a node in another document

Last post 10-17-2005 02:02 AM by Coita Thierry. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 10-14-2005 06:09 AM

    Replace a node in another document

    Hi,

    I have some problem with my code what I try to do is replace the node of my second form by the node of my first form!

    Here is my code:
    ch.powernet.zefix3.GVZ NewTrans = new ch.powernet.zefix3.GVZ();
    XmlDocument XmlSave = new XmlDocument();
    XmlSave.LoadXml(thisXDocument.DOM.xml.ToString());
    XPathNavigator XMLF = XmlSave.CreateNavigator();
    XslTransform xslt = new XslTransform();
    xslt.Load("nonamespace.xsl");
    XmlUrlResolver resolve= new XmlUrlResolver();
    StringWriter result= new StringWriter();
    xslt.Transform(XMLF,null,result, resolve);
    //appel WS et résultat du WS
    string sendWS =result.ToString();
    XmlNode resultWS = NewTrans.putGVZAV(sendWS, "2" );

    XDocument oXdNewForm = thisApplication.XDocuments.NewFromSolution(@"C:\Program Files\InfopathPow\AV.xsn");

    IXMLDOMDocument2 newDocument = (IXMLDOMDocument2)thisXDocument.CreateDOM();
    newDocument.loadXML(resultWS.OuterXml);
    newDocument.setProperty("SelectionNamespaces",
    "xmlns:xsf=\"http://schemas.microsoft.com/office/infopath/2003/solutionDefinition\" , ..."");
    IXMLDOMNode oNode = newDocument.selectSingleNode("/Case");

    IXMLDOMNode AV = oXdNewForm.DOM.selectSingleNode("/CaseList/Case");
    AV.replaceChild(oNode, AV);

    thisApplication.XDocuments.Close(0);

    If I try to do this code that make me an error in line:
    AV.replaceChild(oNode, AV);

    the error is: Insert position Node must be a Child of the Node to insert under.

    So I have think that is because I need to select the parent node I have try:
    IXMLDOMNode AV = oXdNewForm.DOM.selectSingleNode("/CaseList");

    But always the same error!

    Any Idea for this problem?

    If you have any other suggestion for improve my code don't hesitate: post!

    Thanks for your help

    ++

    Thierry


    Every moment hesitated is a moment gone for life!!! Think about it
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 10-17-2005 02:02 AM In reply to

    Re: Replace a node in another document

    Nobody for help me?

    Other question: Is it possible to pass a node between two form like I wan't to do?

    I think I have forget to put my xml code:

    the new xml node:
    <Case Gnr="0" Gyear="2005" Nr="NW-1156-2005" Kanton="NW" Amt="150" SitzNr="1503" CHNR="" Lang="2" valid="1" inBearb="1" Stempel="2005-10-17T08:05:21" Visum="RS " Version="0.1">
    <Geschaeft>
    <Firma>fgsdk</Firma>
    <Bemerkung>Art 89 ORC</Bemerkung>
    <Sitz bfs="1503">Dallenwil</Sitz>
    <Anmelder fldID="114">
    <Empfaenger/>
    <co/>
    <Strasse nr=""/>
    <Zusatz zusNr=""/>
    <PLZ/>
    <Ort/>
    <fullText/>
    </Anmelder>
    <Eingang>2005-10-17</Eingang>
    <Termin>2005-10-27</Termin>
    <Zuteilung>
    <Vis>RS </Vis>
    <Dat>2005-10-17</Dat>
    </Zuteilung>
    <Ende/>
    </Geschaeft>
    <Search>
    <SearchAIM/>
    <SearchPHON/>
    </Search>
    <AV type="Anmeldung" RF="5" GF="1" nextRef="1">
    <AVel TitNr=" " fldID="234" F0="0" F1="1" F2="0" F3="0" F4="0" F5="0" F6="0" F7="1" F8="1" F9="0" F10="0" F11="0" F12="0" F13="0" F14="1" F15="0" fmt="TEXT">
    <Title>En-tête</Title>
    <Text/>
    </AVel>
    </AV>
    </Case>

    the primary datasource xml (template.xml):
    <CaseList xmlns:tsd="http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:tns="http://zefix.powernet.ch/WebServices" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:ns1="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-08-09T07:55:00" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
    <Case Gnr="" Gyear="" Nr="" Kanton="" Amt="" SitzNr="" CHNR="" Lang="" valid="" inBearb="" Stempel="" Visum="" Version="">
    <Geschaeft>
    <Firma></Firma>
    <Bemerkung></Bemerkung>
    <Sitz bfs="" Country=""></Sitz>
    <Eingang></Eingang>
    <Termin></Termin>
    <Ende></Ende>
    </Geschaeft>
    <Search>
    <SearchAIM></SearchAIM>
    <SearchPHON></SearchPHON>
    </Search>
    <AV type="" RF="" GF="" nextRef="" TBnr="" TBdate="" SHABnr="" SHABdate="" SHABpage="" SHABpubl="">
    <AVel TitNr="" fldID="" Flags="" fmt="">
    <Title></Title>
    <Sitz bfs="" Country=""></Sitz>
    <Text></Text>
    </AVel>
    </AV>
    <Bestellung></Bestellung>
    <TB></TB>
    </Case>
    </CaseList>


    If I preview the form in design mode with the new xml node convert as a xml file (I have add the CaseList node at the begin of my xml) that work corectly!

    Thanks for help !

    ++

    Thierry

    Every moment hesitated is a moment gone for life!!! Think about it
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.