How to display XML in HTML in PHP?

If you just want a plain-text representation of your (pre-formatted) string, you can wrap it in HTML <pre/> tags and use htmlentities to escape the angle brackets:

<?PHP echo '<pre>', htmlentities($string), '</pre>'; ?>

Leave a Comment