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

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,894
    Rep Power
    172

    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. Channeling Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    15,160
    Rep Power
    9499
    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,894
    Rep Power
    172
    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. Channeling Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    15,160
    Rep Power
    9499
    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