Module Version: 1.0.03 Source
FMPro::fmp2perl - FMPro- XML-parsing and output of field names, field values and requestparameters as reference.
use FMPro::fmp2perl qw(fmp2perl);
$tmp = <URL>; <File> oder <String>;
$values =fmPperlL($tmp);
$title = $values->[0]{title}{Data}[0];
$database = $values->[0]{CurrentDatabase};
$RecID = $values->[0]{CurrentRecID};
$type = $values->[0]{title}{Type}; # only for FMPXMLRESULT
FMPro::fmp2perl - FMPro- XML-parsing and output of field names, field values and requestparameters as reference.
XML can be given as FMPDSORESULT or FMPXMLRESULT. fmp2perl is executable on Unix, WINDOWS and MAC systems.
Only tested under ActivePerl 5,8.
- String
- contains a XML structure of the form FMPDSORESULT or FMPXMLRESULT. It is considered Utf-8 encoding only.
- Reference to a file
- file contains a XML structure of the form FMPDSORESULT or FMPXMLRESULT. It is considered Utf-8 encoding only.
- URL
- contains a FMPro database request.
Explanations concerning the output-table:
$v = fmp2perl($tmp)
X/U - $tmp is an url in FMPXMLRESULT format
X/FS - $tmp is a path to a file or a string ~
D/U - $tmp is an url in FMPDSORESULT format
D/FS - $tmp is a path to a file or a string ~
Value - e.g. {<name of field>}{data}[0]......$v->[0]{<name of field>}{data}[0]
with
$v ->[0] - First data record
{<name of field>} - Name of the field {Data} - Output of field value
[0] - 0. Repetition of a repetition-field and/or a field without repetition
Wert
|
X/U |
X/FS |
D/U |
D/FS |
{name of fielde>}{CurrentFoundCount} |
x |
x |
|
|
{name of fielde>}{Data}[0..<MaxReapeat>-1] |
x |
x |
x |
x |
{name of fielde>}{EmptyOk} |
x |
x |
|
|
{<name of field>}{MaxReapeat} |
x |
x |
|
|
{<name of field>}{Type} |
x |
x |
|
|
{CurrentFormat} |
x |
x |
x |
x |
{CurrentAction} |
x |
|
x |
|
{CurrentDatabase} |
x |
x |
x |
x |
{CurrentError} |
x |
x |
x |
x |
{CurrentLayout} |
x |
x |
x |
x |
{CurrentLOP} |
x |
|
x |
|
{CurrentMax} |
x |
|
x |
|
{CurrentModID} |
x |
x |
x |
x |
{CurrentOutCount} |
|
|
x |
x |
{CurrentRecordCount} |
x |
x |
|
|
{CurrentSkip} |
x |
|
x |
|
{CurrentSort} |
x |
|
x |
|
{CurrentRecID} |
x |
x |
x |
x |
{CurrentRecordNumber} |
x |
x |
x |
x |
{DateFormat} |
x |
x |
|
|
{ProductBuild} |
x |
x |
|
|
{ProductName} |
x |
x |
|
|
{ProductVersion} |
x |
x |
|
|
{TimeFormat} |
x |
x |
|
|
{URL} |
x |
|
x |
|
|
|
|
|
|
|
|
|
|
|
All variable names were assigned following the CDML syntax. Therefore the reading of the CDML reference is recommended for the meaning of the values.
Only exception: value {CurrentOutCount} ( e.g. $v->[2]{CurrentOutCount} ).
{CurrentOutCount} - Number of data records in the XML structure; only with FMPDSORESULT
use FMPro::fmp2perl qw(fmp2perl);
# Example with url FMPDSORESULT
$tmp = "http://www.domain.com/FMPro?-db=your-database.fp5";
$tmp .= "&-lay=your-layout&-Format=-dso_xml&-FindAll=";
$values =fmp2perl($tmp);
# Example with url FMPXMLRESULT
$tmp = "http://www.domain.com/FMPro?-db=your-database.fp5";
$tmp .= "&-lay=your-layout&-Format=-fmp_xml&-FindAll=";
$values =fmp2perl($tmp);
# Example with path to file (UNIX)
$tmp = "/xml_data/path/fmp_xml_file.xml";
$values =fmp2perl($tmp);
# Example with path to file (WINDOWS)
$tmp = "C:\\Inetpub\\wwwroot\\xml_data_path\\fmp_xml_file.xml";
$values =fmp2perl($tmp);
# Example with FMPB<DSO>RESULT XML structur
$tmp =<<__XML__;
<?xml version="1.0" encoding="UTF-8"?>
<FMPDSORESULT xmlns="http://www.filemaker.com/fmpdsoresult">
<ERRORCODE>0</ERRORCODE>
<DATABASE>YOUR-DATABASE.FP5</DATABASE>
<LAYOUT></LAYOUT>
<ROW MODID="4" RECORDID="32871">
<title>your title</title>
</ROW>
</FMPDSORESULT>
__XML__
$values =fmp2perl($tmp);
# Example with FMPB<XML>RESULT XML structur
$tmp =<<__XML__;
<?xml version="1.0" encoding="UTF-8"?>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
<ERRORCODE>0</ERRORCODE>
<PRODUCT BUILD="5/4/2002" NAME="FileMaker Pro Web Companion" VERSION="6.0v1"/>
<DATABASE DATEFORMAT="d.M.yyyy" LAYOUT="" NAME="YOUR-DATABASE.FP5" RECORDS="4021" TIMEFORMAT="k:mm:ss"/>
<METADATA>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="title" TYPE="TEXT"/>
</METADATA>
<RESULTSET FOUND="1">
<ROW MODID="1" RECORDID="32775">
<COL>
<DATA>your title</DATA>
</COL>
</ROW>
</RESULTSET>
</FMPXMLRESULT>
__XML__
$values =fmp2perl($tmp);
$title = $values->[0]{title}{Data}[0];
$database = $values->[0]{CurrentDatabase};
...
$RecID = $values->[0]{CurrentRecID};
$type = $values->[0]{title}{Type}; # only for FMPXMLRESULT
Starting from version 1.0.03 fmp2perl.pm runs, if missing, also without module Unicode::String.
Hans-Martin Aurich info@webconsultant.de technik@baurat.de
Copyright 2004 - 2005 Hans-Martin Aurich. All rights reserved.
|