Search code examples
htmlxmllinkedin-api

how can i add a line break in XML


hi i am working with linkiedin api , there i have a xml

function send_messeges($access_token, $xml_atring) {

    $profile_url = "http://api.linkedin.com/v1/people/~/mailbox";
    $xml = '<?xml version="1.0" encoding="UTF-8" ?>
        <mailbox-item>
          <recipients>                
            ' . $xml_atring . '
          </recipients>
          <subject>'.$this->send_subject.'</subject>
          <body>'.$this->send_message.'</body>
        </mailbox-item>';
    $request = OAuthRequest::from_consumer_and_token($this->consumer, $access_token, "POST", $profile_url);
    $request->sign_request($this->method, $this->consumer, $access_token);
    $auth_header = $request->to_header("https://api.linkedin.com");
    $response = $this->httpRequest($profile_url, $auth_header, "POST", $xml);        
    return $response;

}

in

$this->send_message

i have a message , i want to add some HTML with message , but linkedin API does not allow me to do that .

even the

<![CDATA[
        Line 1 <br />
        Line 2 <br />
        Line 3 <br />
        ]]>

is not working here , so is there any built in xml tag i can use for line breaks ansd is there any tags equalant to HTML tags . please help

UPDATE

if i use message

"Elephanti <br/> invitation Message, Visite our site http://elephanti.com";

the response is

Invalid xml {Element not allowed: br@http://api.linkedin.com/v1 in element body@http://api.linkedin.com/v1}

Solution

  • Use &#xD in your XML document wherever you want to have the line breaks.

    There's a good explanation at this site: http://www.stylusstudio.com/xmldev/200309/post80050.html

    ANOTHER OPTION

    Try just typing <br/> where you want the space

    EDIT FOR FUTURE VIEWERS

    What worked for him was typing \n where he wanted the line-break