Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11508

How to apply infopath schema definition to my xml file through VS2010

$
0
0

Hi,

I have a Infopath 2010 form which saves data to a form library. The InfoPath form saves data as an xml file in the form library.

I am trying to generate similar xml files through VS2010 but unable to apply the infopath schema definition.

This is how infopath xml file looks (in the form library)

<?xmlversion="1.0"encoding="utf-8"?><?"color:blue">name="urn:schemas-microsoft-com:office:infopath:Lib:-myXSD-2012-10-23T13-01-33" solutionVersion="1.0.0.180" productVersion="14.0.0.0" PIVersion="1.0.0.0" href="http://xxx/Mysite/Lib/Forms/template.xsn"?>

<?"font-size:9.5pt;font-family:Consolas;color:blue">progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?>

<my:myFieldsxml:lang="en-US"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-10-23T13:01:33"xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">

       <my:ID>6d423caa-9723-4aae-8162-28400ac06412</my:ID>

       <my:Schedule>1</my:Schedule>

       <my:PlannedCost></my:PlannedCost>

       <my:EstimatedCost></my:EstimatedCost>

</my:myFields>


xml output through VS2010 code:


<?xml version="1.0" ?>

-<myFields>

 <ID>08A8F24B-2D90-4212-AB50-0094844CCE5B</ID>

 <Schedule>1</Schedule>

   <PlannedCost/>

 <EstimatedCost/>

 </myFields>


Here is my VS2010 function for generating xml output programatically

publicvoid WriteXml()

        {

           XmlTextWriter textWriter = newXmlTextWriter(@"C:\Users\xyz\Desktop\XMLFiles\output.xml",null);

         //  textWriter.

           

            textWriter.WriteStartDocument();

            textWriter.WriteStartElement("myFields");// Start begin tag

            textWriter.WriteStartElement("ID");

            textWriter.WriteString(this.ID);   //setting the ID value

            textWriter.WriteEndElement();

            textWriter.WriteStartElement("Schedule");

            textWriter.WriteString(this.Schedule);   // set schedule value

            textWriter.WriteEndElement();

            textWriter.WriteStartElement("PlannedCost");

            textWriter.WriteString(this.PlannedCost);   //set planned cost

            textWriter.WriteEndElement();

            textWriter.WriteStartElement("EstimatedCost");

            textWriter.WriteString(this.EstimatedCost);  //set estimated cost

            textWriter.WriteEndElement();

            textWriter.WriteEndElement();// End begin tag

            textWriter.Close();

        }

I am missing the schema definition, language and so many other things which should come above the MyFields tags. Please help How the code should be changed.

Thanks.



Viewing all articles
Browse latest Browse all 11508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>