AnsweredAssumed Answered

Building filemaker nested xml structure?

Question asked by kamal1234 on Apr 19, 2016
Latest reply on Apr 21, 2016 by kamal1234

Dear Community Members,

 

I am trying to build filemaker readable xml structure from the regular xml?

I am using php to build it.

 

$returnStr = '';

$returnStr = $returnStr . '<?xml version="1.0" encoding="UTF-8" ?>';

$returnStr = $returnStr . '<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">';

$returnStr = $returnStr . '<ERRORCODE>0</ERRORCODE>';

$returnStr = $returnStr . '<PRODUCT BUILD="04-14-2016" NAME="FileMaker" VERSION="ProAdvanced 14.0v3"/>';

$returnStr = $returnStr . '<DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="IMS.fmp12" RECORDS="1" TIMEFORMAT="h:mm:ss a"/>';

$returnStr = $returnStr . '<METADATA>';

$returnStr = $returnStr . '<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Description" TYPE="TEXT"/>';

$returnStr = $returnStr . '<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="PartNumber" TYPE="NUMBER"/>';

$returnStr = $returnStr . '<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="QtyInPack" TYPE="NUMBER"/>';

$returnStr = $returnStr . '<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="QtyAvailable" TYPE="NUMBER"/>';

$returnStr = $returnStr . '<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="sellPrice" TYPE="NUMBER"/>';

$returnStr = $returnStr . '<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="costPrice" TYPE="NUMBER"/>';

$returnStr = $returnStr . '<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="lcd" TYPE="NUMBER"/>';

$returnStr = $returnStr . '</METADATA>';

$returnStr = $returnStr . '<RESULTSET FOUND="1">';

$returnStr = $returnStr . '<ROW MODID="1" RECORDID="1">';

$returnStr = $returnStr . '<COL>';

$returnStr = $returnStr . '<DATA>'.trim($array_data['stockcheckresp']['part']['@attributes']['desc']).'</DATA>';

$returnStr = $returnStr . '</COL>';

$returnStr = $returnStr . '<COL>';

$returnStr = $returnStr . '<DATA>'.trim($array_data['stockcheckresp']['part']['@attributes']['partno']).'</DATA>';

$returnStr = $returnStr . '</COL>';

$returnStr = $returnStr . '<COL>';

$returnStr = $returnStr . '<DATA>'.trim($array_data['stockcheckresp']['part']['@attributes']['caseqty']).'</DATA>';

$returnStr = $returnStr . '</COL>';

$returnStr = $returnStr . '<COL>';

$returnStr = $returnStr . '<DATA>'.trim($array_data['stockcheckresp']['part']['@attributes']['qtyavail']).'</DATA>';

$returnStr = $returnStr . '</COL>';

$returnStr = $returnStr . '<COL>';

$returnStr = $returnStr . '<DATA>'.trim($array_data['stockcheckresp']['part']['@attributes']['sell']).'</DATA>';

$returnStr = $returnStr . '</COL>';

$returnStr = $returnStr . '<COL>';

$returnStr = $returnStr . '<DATA>'.trim($array_data['stockcheckresp']['part']['@attributes']['cose']).'</DATA>';

$returnStr = $returnStr . '</COL>';

$returnStr = $returnStr . '<COL>';

$returnStr = $returnStr . '<DATA>'.trim($array_data['stockcheckresp']['part']['@attributes']['lcd']).'</DATA>';

$returnStr = $returnStr . '</COL>';

$returnStr = $returnStr . '</ROW>';

$returnStr = $returnStr . '</RESULTSET>';

$returnStr = $returnStr . '</FMPXMLRESULT>';

 

My above xml conversion is working correctly.

 

I want to add data in a loop as a part of the above xml structure.

 

How can I integrate following array into above filemaker xml?

 

How do I define the metadata and column and data  for the structure below as it has multiple elements.

 

 

 

[choice] => Array

                        (

                            [0] => Array

                                (

                                    [@attributes] => Array

                                        (

                                            [lcd] => 12K

                                            [partno] => 1548

                                            [desc] => THROTTLE BDY

                                            [linemfg] => BBK PERFORMANCE

                                        )

 

 

                                )

 

 

                            [1] => Array

                                (

                                    [@attributes] => Array

                                        (

                                            [lcd] => 226

                                            [partno] => 1548

                                            [desc] => STOP THROTTL

                                            [linemfg] => WEATHERHEAD BRASS FITT

                                        )

 

 

                                )

 

 

                            [2] => Array

                                (

                                    [@attributes] => Array

                                        (

                                            [lcd] => 766

                                            [partno] => 1548

                                            [desc] => YOKE

                                            [linemfg] => MOOG U-JOINTS

                                        )

 

 

                                )

 

 

                            [3] => Array

                                (

                                    [@attributes] => Array

                                        (

                                            [lcd] => 82P

                                            [partno] => 1548

                                            [desc] => IGNITOR PRES

                                            [linemfg] => PERTRONIX

                                        )

 

 

                                )

 

 

                            [4] => Array

                                (

                                    [@attributes] => Array

                                        (

                                            [lcd] => VT

                                            [partno] => 1548

                                            [desc] => ORIGINALS

                                            [linemfg] => V-TECH

                                        )

 

 

                                )

 

 

                        )

 

Thank you,

Kamal.

Outcomes