<?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))
]
);
}
- Output for 7.1.25 - 7.1.31, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
- array(2) {
["code"]=>
string(5) "47156"
["name"]=>
string(4) "BARB"
}
array(2) {
["code"]=>
string(1) "1"
["name"]=>
string(6) "GREATN"
}
array(2) {
["code"]=>
string(5) "89252"
["name"]=>
string(5) "DERIN"
}
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
array(2) {
["code"]=>
string(5) "47156"
["name"]=>
string(4) "BARB"
}
array(2) {
["code"]=>
string(1) "1"
["name"]=>
string(6) "GREATN"
}
array(2) {
["code"]=>
string(5) "89252"
["name"]=>
string(5) "DERIN"
}
preferences:
170.17 ms | 402 KiB | 172 Q