Print xml with php

后端 未结 4 1197
北荒
北荒 2020-12-22 08:53

I have this php code

    \\n\";
    echo \"\\n\";
    echo \"\\t<         


        
相关标签:
4条回答
  • 2020-12-22 09:26

    you have to put header (to let the browser know how to render the display):

    header ("Content-Type:text/xml");
    
    0 讨论(0)
  • 2020-12-22 09:26

    You have to use proper content-type, as the others have said. I recommend you to use XMLReader. Or if you want a n easier way, then try to use Heredoc string syntax with sprintf and htmlspecialchars to encode values with characters that have special meanings in XML (like <>&)

    0 讨论(0)
  • 2020-12-22 09:28

    Try viewing your source, the xml is there but just not visible. Your browser will try to show the page as HTML, since you dont supply the correct headers. Since there are no tags, you wont see anything.

    You should send the correct headers, as such:

    header('content-type: text/xml')
    
    0 讨论(0)
  • 2020-12-22 09:41

    As the others have said, you need to give the browser a header to let it know how to display the page.

    As for xml functions, have a look at the PHP SimpleXMLElement

    0 讨论(0)
提交回复
热议问题