locked
Download InfoPath xml form as HTML RRS feed

  • Question

  • Hi Everyone,

    I am looking for a way to download InfoPath xml forms from SharePoint as HTML programmatically ,
    I tried using C# WebClient but it didnt work so far..
    the client can view the forms already as HTML within IE and I am looking for a way to download that html file.

    I found a way to download the form XML file and then use the xsn template to transform the file to HTML but not all controles will be

    transformed and thought maybe there is an easier way to do this though either the forms service or document conversion ?


    thanks.
    • Edited by cool_misbah Monday, January 9, 2012 3:51 PM
    Monday, January 9, 2012 3:49 PM

All replies

  • How about an mht file?  I wrote the code below for someone else who was using VB, sorry I don't have it readily available in c#.  You would add the following code to a button or a field's changed event, etc:

     

            Public Sub CTRL3_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
                ' Write your code here.
                Dim filename As String
                Dim nameNode As XPathNavigator
                nameNode = MainDataSource.CreateNavigator.SelectSingleNode("/my:myFields/my:field1", NamespaceManager)
                Dim tsNode As XPathNavigator
                tsNode = MainDataSource.CreateNavigator.SelectSingleNode("/my:myFields/my:field2", NamespaceManager)
                filename = nameNode.Value + tsNode.Value + ".mht"
                Me.CurrentView.Export("C:\Users\smithj\Downloads\" + filename, ExportFormat.Mht)
    
    **I have not tested this on a browser-enabled form, so I'm not sure if it's browser compatible or not in case your form is a browser form.

    Tuesday, January 10, 2012 2:56 PM
  • Thanks a lot Melissa ,

    I am wondering where are you executing this code ?

    I have a connector (windows app) that connect to SharePoint and extract the content and I wanted to add the ability to convert the extracted InfoPath forms from XML to HTML, it looks like your code run within a SharePoint page, I am not sure how to incorporate such code to my connector :(

    Wednesday, January 11, 2012 3:55 PM