Failure to import XML data into a form
For a long time now, I have been using a script to import data from XML data files into a LiveCycle form, using a script originally offered by @radzmar . That script starts as follows:
function importXML(){
// Wenn PDF-Viewer älter als 9.2 ist, funktioniert der Import nicht!
if (parseFloat(app.viewerVersion) < 9.2) {
xfa.host.messageBox("You must use Adobe Reader version 9.2 or greater for this import function to operate.", "Your version of Adobe Reader is too old", 0, 0);
} else {
// Externe Datei laden.
var vStream = util.readFileIntoStream();
if (vStream) {
var vImport, vImportData, vImportXML, vNGEXML;
try {
// Die folgende Zeile sieht nur weges des regulären Ausdrucks aus, als ob sie auskommentiert wäre, ist aber sehr wichtig!!!
vImport = util.stringFromStream(vStream)
.replace(/(\<\?.*\?\>\s*)|(\<!-{2}(.|\n|\r)*-{2}\>)|(\r\n|\r|\n)/g, "");
vImportData = eval(vImport);
vImportXML = vImportData.toXMLString();
// Assign the XML code as a string value to Textfield1
form1.SfDataImport.TfAurImport.rawValue = vImportXML;
Occasionally, that import script failed and I figured it was because the XML data file included curly brackets {} in the data fields.
I am wondering if there is a way to modify the script so it would not fail but replace curly brackets by parentheses and therefore prevent the script's failure.
By the way, can you explain what the following line does in that script?
.replace(/(\<\?.*\?\>\s*)|(\<!-{2}(.|\n|\r)*-{2}\>)|(\r\n|\r|\n)/g, "");
Thank you in advance.