The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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