Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

PHP XMLAPI: Formatting fetchautoresponder output

Discussion in 'cPanel Developers' started by iSofia, Oct 8, 2014.

  1. iSofia

    iSofia Member

    Joined:
    Jun 3, 2014
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hello everyone. Is there any way to format the BODY string returned by the fetchautoresponder function? It is set to return XML format ($xmlapi->set_output("xml")) but the output seems to disregard all line breaks and displays the entire body in a single line. This is the extraction code:

    Code:
    $xml_object = simplexml_load_string($cpResponse); 
    foreach($xml_object->data as $key => $value) 
    { 
      echo "sender: ".$value->from."<br>";
      echo "subject: ".$value->subject."<br>";
      echo "contents: ".$value->body."<br>";
    }
    Thank you. :)
     
  2. iSofia

    iSofia Member

    Joined:
    Jun 3, 2014
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Although this may not be the ultimate solution, I've found a workaround. The XML string could either be displayed within <pre> tags, or formatted with the {whitespace: pre-wrap} style. The string would then be displayed with the line breaks.

    If anyone knows of a way to re-format the string, and replace these line breaks with HTML <br> tags, that would be great.

    Thank you. :)
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice