How to judge a newline for RKD news

hi Team,

customer asked how to deal with new line character for RKD API ? could you pls advise it ?

Thanksimage

Tagged:

Best Answer

  • wasin.w
    wasin.w admin
    Answer ✓

    Hello @gang.chen1

    I am wondering about how the raw JSON message that the application gets from the API looks like.

    Based on my test with Postman and other programming languages, the news story content has a proper space, tab, etc from the API.

    image

    Then I just get the News Story from JSON response message "TE" property and set it to the HTML "as is". Since the news message came inside the HTML <pre> tag from the API, so all preformatted text should be present "as is".

    xhr.onreadystatechange = function(){
       if (this.readyState === XMLHttpRequest.DONE && this.status === 200){
          ...
          let jsonResponse = JSON.parse(xhr.responseText);
          msg = jsonResponse['RetrieveStoryML_Response_1']['StoryMLResponse']['STORYML']['HL'][0]['TE'];
          divMsg = document.getElementById('news_result');
          divMsg.innerHTML = msg;
    ...

    The result has a correct aligned, indent, and tabs.

    image

Answers