- ob_start: documentation ( source)
- simplexml_load_string: documentation ( source)
- ob_end_flush: documentation ( source)
- ob_get_contents: documentation ( source)
<?php
$data = '<?xml version="1.0" encoding="utf-8" ?>
<note>
<to>
<form>pswA</form>
<heading>A</heading>
</to>
<to>
<form>pswB</form>
<heading>A</heading>
</to>
</note>';
$xml = simplexml_load_string($data);
foreach ($xml->to as $to){
if ($to->form == 'pswA' && $to->heading == 'A'){echo "allow";}
elseif ($to->form == 'pswA' && $to->heading == 'B'){echo "notallow";}
elseif ($to->form == 'pswA' && $to->heading == 'C'){echo "block";}
}
ob_start();
foreach ($xml->to as $to){
if ($to->form == 'pswA' && $to->heading == 'A') echo "allow";
elseif ($to->form == 'pswC' && $to->heading == 'B') echo "notallow";
elseif ($to->form == 'pswC' && $to->heading == 'C') echo "block";
}
if(!ob_get_contents()) echo "empty";
ob_end_flush();
?>