Forum Moderators: coopster

Message Too Old, No Replies

PHP display raw XML code

How to stop IE from parsing?

         

bcolflesh

9:07 pm on May 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have some XML data in a MySQL text field that I want to display "as-is" on a PHP page - if I echo the contents, IE parses & just displays the contents and not the XML markup.

I'm sure I'm overlooking an obvious solution - what is it?

Regards,
Brent

daisho

12:19 am on May 2, 2003 (gmt 0)

10+ Year Member



try to wrap it in <pre> </pre> tags. This tells the web browser to display the content asis (ie no parsing)

daisho.

daisho

1:26 pm on May 2, 2003 (gmt 0)

10+ Year Member



Sorry bcolflesh it doesn't look like my last suggestion would work. Look into the htmlentities() function it will convert all HTML special chars to encoded chars. You may still want to use the <pre> tags for readability.

daisho

bcolflesh

1:30 pm on May 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Daisho - thanks for the reply - you are correct that it doesn't cure my issue - but it does make for nice formatting.

How do these forums or code snippet websites display the raw XML inline? Must be more complicated than wrapping it in some tag I don't know about.

Regards,
Brent

grahamstewart

1:37 pm on May 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try the htmlentities() function.

daisho

2:04 pm on May 2, 2003 (gmt 0)

10+ Year Member



As I noted (though not very clearly) in msg3, and that grahamstewart suggests use the PHP function htmlentities() on your XML data to encode all HTML special chars.

daisho.

bcolflesh

2:20 pm on May 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm afraid I should have mentioned that I was trying that next - and it works!

Thank you to both you guys(?) - I appreciate the help.

Regards,
Brent