core_course_get_courses course summary value

core_course_get_courses course summary value

by Elie Reformed -
Number of replies: 4

Hi, I get the XML result from core_course_get_courses, the problem is that I have this html css added to the course summary for example:  

<KEY name="summary">
<VALUE>
<span style="line-height:22.4px;">Course summary blah blah blah.....</span>
</VALUE>
</KEY>

What I want is :

<KEY name="summary">
<VALUE>
Course summary blah blah blah....
</VALUE>
</KEY>

Thanks.


Average of ratings: -
In reply to Elie Reformed

Re: core_course_get_courses course summary value

by Elie Reformed -

It was easy to solve, what I did was that I clicked on the HTML button in the course summary and do what I had to do...


In reply to Elie Reformed

Re: core_course_get_courses course summary value

by Matt Perkins -

I solved this by using some Javascript in my application to strip out the HTML. 

Average of ratings: Useful (1)
In reply to Matt Perkins

Re: core_course_get_courses course summary value

by Elie Reformed -

Nice, it would be dope if you share it with us? smile

In reply to Elie Reformed

Re: core_course_get_courses course summary value

by Matt Perkins -

Sure! smile I typed up this example in the editor so I can't garuntee they'll work 100%, but the functions below are what I'm using. I can't take credit for the Regex, I think I found it on stackoverflow a while back.


// Example

var summary = "<h1>Some title</h1><p>This is <span>&gt;cool!&lt;</span></p>"

var cleanedSummary = removeEntity(removeTags(summary));

// cleanedSummary will be "Some title This is cool!"



// Remove all HTML tags from a string

function removeTags(str) {

  return str.replace(/(<([^>]+)>)/ig, '');

}


// Remove all HTML entities such as &gt; &nbsp;

function removeEntity(str) {

  return str.replace(/(&(#?)(?:[a-z\d]+|#\d+|#x[a-f\d]+);)/ig, '');

}