Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > contrib-release > by-pkgid > 505554504690f7239244db2c4eb0475c > files > 4

php-pear-XML_Beautifier-1.2.0-4mdv2010.1.noarch.rpm

<?PHP
/**
* XML_Beautifier example 2
*
* This example displays the formatString()
* method which can be used to beautify an XML string instead
* of a file.
*
* @author	Stephan Schmidt <schst@php.net>
*/
	error_reporting( E_ALL );

    $xmlString = '<xml><foo bar="tomato &amp; Cheese"/><argh>foobar<![CDATA[ Test
	Test ]]></argh></xml>';

    require_once 'XML/Beautifier.php';
    $fmt = new XML_Beautifier();
    $result = $fmt->formatString($xmlString);

    echo "<h3>Original string</h3>";
    echo "<pre>";
    echo htmlspecialchars($xmlString);
    echo "</pre>";
        
    echo    "<br><br>";
    
    echo "<h3>Beautified string</h3>";
    echo "<pre>";
    echo htmlspecialchars($result);
    echo "</pre>";
?>