Simple imports in stand-alone IP

L

lee

I've seen this question answered all over the web with lots of complex
solutions. Also no answers as to how to get the required (secure)
absolute path for a .XML. Here's a simple solution.

Prerequisites:

0. IP security requires knowing the fully qualified path of .xml
files,
e.g. "c:\\path\\path\\file.xml"
Relative paths won't work ("\.\\file.xml" or simply "file.xml")

1. Form is constructed from (MS Access exported) .xsd schema only. No
data (no xml).
2. Data is merged from .xml only (MS Access exported). No .xsd file or
xsd schema.

(this makes the data-to-form match a very good 1:1 match for using the
simple XDocument.ImportFile() method. ImportFile() is the equivalent
of the "File --> Merge" UI command in IP.

3. Form name is known and .xml data is dumped in the same working
directory.

// get fully qualified path
var s = XDocument.Solution.URI;

// Look for form name in path
// If can't find the proper string then we might be in the wrong
// path, like with Preview mode
if ( s.indexOf( "myformfilename.xsn" ) < 1 )
{ XDocument.UI.Alert( "Form file not found in /n" + s + "/nCan't
import .xml" ) }
else
{
// replace the .xsn filename with the .xml data file name
var sPath = s.replace(/myformfilename.xsn/i, "");
var sXMLFile = sPath + "mydatafilename.xml" ;

// import the data from the xml file
XDocument.ImportFile( sXMLFile );
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top