Retrieve browser-enabled form as XML - InfoPath Dev
in

InfoPath Dev

Retrieve browser-enabled form as XML

Last post 10-18-2006 02:40 AM by hurtlingturtle. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 10-04-2006 08:22 AM

    Retrieve browser-enabled form as XML

    I am trying to use a URL request (via WebRequest.Create) to programmatically retrieve an InfoPath XML document from a document library using the following VB code:

    Dim formXml As String = ""
    Dim req As WebRequest = WebRequest.Create("http://server/doclib/file.xml")
    req.Credentials = CredentialCache.DefaultNetworkCredentials
    req.Method = "GET"

    Dim resp As WebResponse = req.GetResponse()
    Using s As Stream = resp.GetResponseStream(), sr As New StreamReader(s)
    formXml = sr.ReadToEnd()
    End Using

    This works as long as the form template is not browser-enabled. However, if the form template is browser-enabled and the document library is set to "Display as a web page", the request always returns the HTML generated by Forms Services.

    Is there an alternate way to programmatically retrieve the actual XML for the document without using the SharePoint web services or object model?
  • 10-18-2006 02:40 AM In reply to

    Re: Retrieve browser-enabled form as XML

    Use the following code:

    SPSite site = new SPSite("http://" + _serverName);
    SPWeb web = site.OpenWeb();
    SPListItem listItem = web.GetListItem("http://" + _serverName + _formLocation);
    String fileXML = listItem.Xml;

    hope this helps
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.