If you're trying to pull data out of a FileMaker XML record export you could use the SimpleXML tools like SimpleXMLElement
to access the data within the nodes:
$string = <<<XML
<?xml version="1.0" encoding="UTF-8" ?>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
<ERRORCODE>0</ERRORCODE>
<PRODUCT BUILD="04-17-2014" NAME="FileMaker" VERSION="ProAdvanced 13.0v3"/>
<DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="XMLTest.fmp12" RECORDS="3" TIMEFORMAT="h:mm:ss a"/>
<METADATA>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="id" TYPE="NUMBER"/>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="test" TYPE="TEXT"/>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="name" TYPE="TEXT"/>
</METADATA>
<RESULTSET FOUND="3">
<ROW MODID="3" RECORDID="1">
<COL>
<DATA>1</DATA>
</COL>
<COL>
<DATA>test</DATA>
</COL>
<COL>
<DATA>Chris</DATA>
</COL>
</ROW>
<ROW MODID="3" RECORDID="2">
<COL>
<DATA>2</DATA>
</COL>
<COL>
<DATA>jaslfk;jad</DATA>
</COL>
<COL>
<DATA>Ruthie</DATA>
</COL>
</ROW>
<ROW MODID="3" RECORDID="3">
<COL>
<DATA>3</DATA>
</COL>
<COL>
<DATA>iiiii</DATA>
</COL>
<COL>
<DATA>Zoe</DATA>
</COL>
</ROW>
</RESULTSET>
</FMPXMLRESULT>
XML;
// This is required for FileMaker record exports since they're namespaced
$string = str_replace('xmlns=', 'ns=', $string);
$xml = new SimpleXMLElement($string);
$result = $xml->xpath('//RESULTSET');
echo "<pre>";
foreach($result[0]->children() as $row){
echo "<ul>";
// This shows how you can pull the specific attributes from a give node.
echo "<li>record: " . $row->attributes()->RECORDID->__toString() . "</li>" ;
echo "<ul>";
// This shows how you can drill down to a specific node and pull a node value.
foreach($row->COL as $column){
echo "<li>" . $column->DATA->__toString() . "</li>" ;
}
echo "</ul>";
echo "</ul>";
}
A couple of special notes:
- The line
$string = str_replace('xmlns=', 'ns=', $string);
is required because FileMaker namespaces it's xml - I'm using xpath to grab the values, but you can also use the SimpleXMLIterator tool to walk through the structure as well