Hey guys, I am trying to get only the text from the p tag inside of CDATA for description. I could render Cdata in my code component but the <p> tag is still inside of the text. I want to only render the first P tag Please help!
$(document).ready(function() {
$.ajax({
url: "https://somethignsomething.com",
dataType:'xml',
type:'GET',
success: function(result) {
var my_blog = $(result).find('channel item').first();
console.log(result)
// var my_link = my_blog.find('link').parent().attr('href');;
// var my_link = my_blog.find('link').attr('href');
var my_title = my_blog.find('title').text();
var my_description = my_blog.find('description').text();
var img = my_blog.find('content\\:encoded, encoded').text();
img = $.parseHTML(img);
img = img[0].firstChild.src;
var oldSrc = 'https://cdn11.net/m/resources/img/teaser/rht-full-blogteaser-medium-smartphones-290x268.jpg';
var newSrc = img;
$('img[src="' + oldSrc + '"]').attr('src', img);
$('.text-content').replaceWith(
$('<h2 />',{
text: my_title
}),
$('<p />',{
text: my_description
}),
)
},
error: function(error) {
console.log(error);
}
});
});
