Saving InfoPath Forms to SQL Server 2005 as XML
page 3 of 7
by S.Y.M. Wong-A-Ton
Feedback
Average Rating: 
Views (Total / Last 10 Days): 40624/ 70

Design the InfoPath form

Create a new InfoPath form that has a Date Picker control, a Text Box control, a Rich Text Box control, a File Attachment control, and a Picture control as shown in Figure 1.

Figure 1

savetosqlasxml.png

To be able to save this form to SQL Server as typed XML, i.e. XML data that has been associated with an XML schema, you must know what the XML schema for the InfoPath form is before you can create the database table. Perform the following steps to extract the XML schema for the InfoPath form:

1.    On the File menu, click Extract Form Files.

2.    In the Browse for Folder dialog box, select a folder to save the extracted files in and click OK.

3.    Open Windows Explorer and navigate to the folder where you saved the extracted files.

4.    Open the myschema.xsd file to view and copy the XML schema for the InfoPath form (see Listing 1).

Listing 1: XML schema for the InfoPath form

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema
 targetNamespace="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-12-16T23:41:41"
 xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-12-16T23:41:41"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="myFields">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="my:field1" minOccurs="0"/>
        <xsd:element ref="my:field2" minOccurs="0"/>
        <xsd:element ref="my:field3" minOccurs="0"/>
        <xsd:element ref="my:field4" minOccurs="0"/>
        <xsd:element ref="my:field5" minOccurs="0"/>
      </xsd:sequence>
      <xsd:anyAttribute processContents="lax" namespace="http://www.w3.org/XML/1998/namespace"/>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="field1" nillable="true" type="xsd:date"/>
  <xsd:element name="field2" type="xsd:string"/>
  <xsd:element name="field3">
    <xsd:complexType mixed="true">
      <xsd:sequence>
        <xsd:any minOccurs="0" maxOccurs="unbounded"
 namespace="http://www.w3.org/1999/xhtml" processContents="lax"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="field4" nillable="true" type="xsd:base64Binary"/>
  <xsd:element name="field5" nillable="true" type="xsd:base64Binary"/>
</xsd:schema>

View Entire Article

User Comments

No comments posted yet.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-20 7:27:34 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search