Search code examples
xmlinfopath

Dynamic data loading from a XML file to InfoPath form


I have a bunch of XML files (say: xml1.xml, xml2.xml, xml3.xml...etc.)

Note: All the xml files have same tags (but generated for different dates).

I also have an Info Path form with the fields same as the tags in the above xml files. All I need is to "dynamically" load or populate the form with the data present inside the above XML files.

FYI: When ever we start this form it should fetch the data from the xml files dynamically.

I am using InfoPath2010.


Solution

  • The only solution (I know) for importing XML files, generated by another source, into InfoPath is by editing the XML file.

    1) Analyse a XML file, which is generated by InfoPath. After the xml definition there is a mso-infoPathSolution tag. The file should look something like this.

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <?mso-infoPathSolution solutionVersion="1.0.0.71" productVersion="12.0.0" ...
    

    2) Copy the mso-infoPathSolution tag into the XML which you want to open with your InfoPath form. Make sure that you copy that tag after the XML definition.

    3) Open the XML file with right click and "open with..." options. Choose InfoPath or open InfoPath and open your XML file out of InfoPath. Ready. The data of the XML file is inside the InfoPath form.

    The editing of the header is important, because without that information InfoPath don't know how it should render the XML. That step could be also solved via another script.