How to display XML in HTML in PHP?

Posted by tomaszs on Stack Overflow See other posts from Stack Overflow or by tomaszs
Published on 2010-05-19T09:36:35Z Indexed on 2010/05/19 9:40 UTC
Read the original article Hit count: 164

Filed under:
|
|

Hello,

I have a string with XML:

$string = 
"
<shoes>
    <shoe>
       <shouename>Shoue</shouename>
    </shoe>
</shoes>
";

And would like display it on my website like this:

This is XML string content:
<shoes>
    <shoe>
       <shouename>Shoue</shouename>
    </shoe>
</shoes>

So I would like to do it:

  • on site, not in textbox
  • without external libraries, frameworks etc.
  • formatted with proper new lines
  • formatted with tabs
  • without colors etc., only text

So how to do it in plain and simple way?

© Stack Overflow or respective owner

Related posts about Xml

Related posts about php