views:

209

answers:

3

hi, I have an InfoPath form in a SharePoint workflow. I'm trying to use a blank copy of the XML produced by the InfoPath to create new instances of the form for the document library to start the workflow, thats not where my problem is. I have an app which copies the file to the document library but when i try to populate the XML i get this error:

Data at the root level is invalid. Line 1, position 1

at the line which reads

doc.LoadXml("copiedFile.xml");

I have no idea why it does the, as to my knowledge the XML is well formed (as this is done automatically by InfoPath) so i can't see where the problem is.

the first four lines of the XML are as follows:

<?xml version="1.0" encoding="utf-8"?>  
<?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:InfoPathForm:-myXSD-2009-10-12T13-20-27" solutionVersion="1.1.0.84" productVersion="12.0.0.0" PIVersion="1.0.0.0" href="http://seed-dev1/FormServerTemplates/InfoPathForm%5B3%5D.xsn"?&gt;
<?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?>
<my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-10-12T13:20:27" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-US">
A: 

Your XML document header seems ok, but I can bet on encoding-related problems.

Can you please post your code to create that XML file? Have you noted a "strange" first character in your file content?

Rubens Farias
The XML is created automatically by InfoPath. the file is created by doing a File.Copy on a blank version of the form
harryovers
can you open your original file? maybe your problem lies on a previous step
Rubens Farias
A: 

I have had this sort of problem before. I am not sure what caused it, propbably the encoding.

Open the file in a program like notepad2. Whatever you use, You need to see the whitespace. The first couple of charaters will be gibberish. delete the whitespace and then save the document.

then give your app ago.

Hopefully it will work for you.

Nathan Fisher
+2  A: 

Could try giving...

doc.Load("copiedFile.xml");

a go.

MoominTroll
cheers that worked!
harryovers