Problem escaping text which contains html markups

To escape html content you can use wp_kses function.

$allowed = array(
    'li' => array(),
    'a' => array(
        'href' => true,

echo wp_kses('<li><a href="#" target="_blank">Category</a></li>', $allowed);

If you do not want to pass allowed array you can use default WordPress array for post content which is used in wp_kses_post function.

echo wp_kses_post('<li><a href="#" target="_blank">Category</a></li>');