Reputation: 157
I need to uncomment CSS code inside a style element (and I need to do this in Java). Consider the following html code:
<html>
<head>
<style type="text/css">
<!--
.big {
font-size: 30px;
}
-->
</style>
</head>
<body></body>
</html>
Here is the desired result:
<html>
<head>
<style type="text/css">
.big {
font-size: 30px;
}
</style>
</head>
<body></body>
</html>
I usually use Jericho to do HTML parsing.
UPDATE. Solved:
String newHtmlString = htmlString.replaceAll("<style><!--", "<style>").replaceAll("--></style>", "</style>");
Upvotes: 0
Views: 165
Reputation: 2116
If the only comment in your file is CSS comment, you might consider something like :
String html = ...; //HTML in String
html.replaceAll("<!--", "");
html.replaceAll("-->", "");
Upvotes: 3