#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,664
    Rep Power
    171

    Displaying xml code in the html or php page


    Hello;

    I need to display xml code in html page's div.

    I tried here but it is not working. If you scroll down you see some strange cde in the divs.

    I tries <pre> or <code> but no luck.

    What do you recommend?

    Thank you
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,072
    Rep Power
    9398
    The browser will try to treat the XML as if it were HTML.

    Use a PRE and htmlentities() the XML.
  4. #3
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,664
    Rep Power
    171
    Originally Posted by requinix
    The browser will try to treat the XML as if it were HTML.

    Use a PRE and htmlentities() the XML.
    Can't! It closes the php
    PHP Code:
    <?php echo '
    <?xml *version="1.0"?><?xml *version="1.0"?>
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,072
    Rep Power
    9398
    It won't if you put it in a string. Or a heredoc:
    PHP Code:
    <pre><?php echo htmlentities(<<<XML
    <?xml version="1.0"?>
    <foo />
    XML
    ); 
    ?></pre>

IMN logo majestic logo threadwatch logo seochat tools logo