- var_dump: documentation ( source)
- trim: documentation ( source)
<?php
$xml = <<<'XML'
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<CMan_Code>47156</CMan_Code>
<CMan_Name>BARB </CMan_Name>
</Table>
<Table diffgr:id="Table2" msdata:rowOrder="1">
<CMan_Code>1</CMan_Code>
<CMan_Name>GREATN </CMan_Name>
</Table>
<Table diffgr:id="Table3" msdata:rowOrder="2">
<CMan_Code>89252</CMan_Code>
<CMan_Name>DERIN </CMan_Name>
</Table>
</NewDataSet>
</diffgr:diffgram>
XML;
$document = new DOMDocument();
$document->loadXML($xml);
$xpath = new DOMXpath($document);
foreach ($xpath->evaluate('//NewDataSet/Table') as $tableNode) {
var_dump(
[
'code' => trim($xpath->evaluate('string(CMan_Code)', $tableNode)),
'name' => trim($xpath->evaluate('string(CMan_Name)', $tableNode))
]
);
}