Modifying InfoPath manifest.xsf file from script (3/5)

Part 3 of 5: Modifying the XSF


Because manifest.xsf file is just a plain xml file, the easiest way to modify it is to open it in an XML DOM, find the corresponding attributes with XPath, and replace their existing values with new data.


We will divide the process in two functions. The first one will be responsible for opening and saving the xml file. The second one will find and modify the attribute value.


The serviceURL and wsdlURL parameters are strings with values like “http://mywebservice” and “http://mywebservice?WSDL” accordingly.


var XsfNamespace =


var XpathToServiceUrl =


var XpathToWsdlUrl =



function FixupXSF(xsfInputPath, xsfOutputPath, serviceURL, wsdlURL)


      var Fso = new ActiveXObject ("Scripting.FileSystemObject");

      var Dom = new ActiveXObject("msxml2.domdocument.5.0");



      Dom.validateOnParse=false; // for ignoring xsi:nil errors..



                  "xmlns:xsf='" + XsfNamespace + "'");


      // serviceURL

      if(serviceURL != null)


            ModifyAttribute(Dom, XpathToServiceUrl, serviceURL);



      // wsdlURL

      if(wsdlURL != null)


            ModifyAttribute(Dom, XpathToWsdlUrl, wsdlURL);



      if (Fso.FileExists(xsfOutputPath))

            Fso.DeleteFile(xsfOutputPath, true);   ;



function ModifyAttribute(dom, xpath, value)


      var AttributeList = dom.selectNodes(xpath);

      for (;;)


            var Attribute = AttributeList.nextNode();

            if(Attribute == null)


            Attribute.nodeValue = value; 




The XSF file was modified. Now we should restore our XSN and we will do it in the next part of the series.


Comments (1)

  1. Ken Brubaker says:

    How to programmatically extract/manipulate/combine an InfoPath Template (XSN) file.

Skip to main content