Dieses Plugin stellt Funktionen zum Parsen, Lesen und Erzeugen von XML-Dateien zur Verfügung.
Das folgende Skript iteriert über eine anzugebende XML-Datei und gibt die Knotennamen sowie die -inhalte im Debugfenster aus.
// **************************************************************// * sample_i2dxxml.i2dspt *// * *// * Sample script for the i2dxXML (reading and writing of xml *// * files) plugin *// * REQUIRES THE INSTALLED PLUGIN TO COMPILE AND RUN! *// * *// * Press F9 to execute the code or F7/F8 to debug it *// * *// * Contact www.norpa.eu if the plugin is required but missing *// **************************************************************{$I i2dxXML}procedure RecurseNodes(ParentNodeName:String);var
i, j:Integer;
s:String;begin
j := i2dxXMLNodeCount(ParentNodeName);for i :=0to j -1dobegin
s := i2dxXMLNodeNameByIndex(ParentNodeName, i)
i2dDebugOut(s +': '+ i2dxXMLGetNodeValue(s));
RecurseNodes(s);end;end;var
sXMLFileName:String;begin
sXMLFileName := i2dInputBox('XML-Filename','XML-Filename to parse:','');if sXMLFileName =''then
i2dCancelProcess('No filename entered');
i2dxXMLLoadDocumentFromFile(sXMLFileName);
RecurseNodes(i2dxXMLRootNodeName);end.
// ***************************************************************// * sample_3.i2dspt *// * *// * - Retrieving the text from all pages of an image using OCR *// * - Saving the result in a textfile named "sample_result.txt" *// * located in the root path of the currrent drive *// * *// * Press F9 to execute the code or F7/F8 to debug it *// * *// * Be sure that the sample data was installed! *// * *// * Contact www.norpa.eu for more information *// ***************************************************************var// Declare some variables
i:Integer;
iPageCount:Integer;
sText:String;
oPage: TBitmap;
oText: TStringList;
rProcessSettings: Ti2dProcessSettings;begin// Get the configured process settings. We must know the configured "in"-folder because that's// where the sample docs are located in!
i2dGetProcessSettings(rProcessSettings);// Create the bitmap object
oPage := TBitmap.Create;// Create the stringlist object
oText := TStringList.Create;try// Get the number of pages from the image file
iPageCount := i2dGetImagePageCount(rProcessSettings.InPath+'sample_invoice_5.tif');for i :=1to iPageCount dobegin// Load page number i of the image into the bitmap object
i2dLoadBitmap(rProcessSettings.InPath+'sample_invoice_5.tif', i, oPage);// Perform a character recognition (ocr) with format preservation on the bitmap object
sText := sText + i2dOCRBitmap(oPage,0,True);// Insert a pageend tag for optical reasons
sText := sText +#13#10'<page end>'#13#10;end;// Pass result to the stringlist object
oText.Text:= sText;// Save stringlist to file
oText.SaveToFile('\sample_result.txt');finally// Destroy the bitmap object and release memory
oPage.Free;// Destroy the stringlist object and release memory
oText.Free;end;end.