Exemplo n.º 1
0
        header('Content-Type: text/xml');
        echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n";
        echo "<response>\n";
    }
    function command($method, $params = array(), $encoded = array())
    {
        echo "  <command method=\"{$method}\">\n";
        if ($params) {
            foreach ($params as $key => $val) {
                echo "    <{$key}>" . htmlspecialchars($val) . "</{$key}>\n";
            }
        }
        if ($encoded) {
            foreach ($encoded as $key => $val) {
                echo "    <{$key}><![CDATA[{$val}]]></{$key}>\n";
            }
        }
        echo "  </command>\n";
    }
    function end()
    {
        echo "</response>\n";
        exit;
    }
}
$retval = "output of PHP script";
$xml = new xmlResponse();
$xml->start();
$xml->command("setstyle", array("target" => "output", "property" => "display", "value" => "block"));
$xml->command("setcontent", array("target" => "samplecode"), array("content" => htmlentities($retval)));
$xml->end();