4
In my project I need to read the contents of an HTML file as said in that question of mine. What happens is I can scan the file, but there’s a comment I wanted to take out.
The peculiarity is that this comment is always changeable, so how can I get c# to remove all the code snippets that appear ?
The comment that appears is this one:
<!-- saved from url=(0103)https://sistema.registrocivil.org.br/buscas/certidoes2aViaGerarXmlBusca.cfm?pedido_certidao_id= -->
Is there any way I can get these comment elements out of HTML(<!---->
) and everything that’s inside that element ? Because it’s always changeable, you can’t use Replace and take.
I wonder if someone could help me ?
That’s right, this is the best solution for prolema.
– Luã Govinda Mendes Souza
So it doesn’t capture multi-line comments. You have to use
RegexOptions.Singleline
to handle the inputstringHtml
as if it were a single line.– dcastro
@Marcusvinicius only an addendum, it would be possible to use a regex to remove tags from HTML, like
<html>
,</body>
, leaving XML content there intact ?– Érik Thiago
Although the comment is directed to Marcus, I say yes. Just follow the model of Marcus. Regex is simple, there is no complication. You will replace what is in the expression with another that in the case of Marcus is a string.Empty, that is, empty. Then just use your imagination you go far. Good code.
– pnet
@pnet I have tried, only what happens is that it takes all tags, including xml tags, and I need to keep them, if not my logic of reading the page does not work. = (. Could you help ? If you know anything, it would be of great help! I didn’t want to open another question, because I think it’s the same theme that you have here. =(
– Érik Thiago
It is better to open another question, otherwise the guys will block the question, since this is more direct, ie HTML tags and BODY. Trust me, open a specific one. Here, it is better to open several questions than to try to amend one, then the downvotes will run loose until the blocking of the question. Because you have already closed and many people do not see questions with answers already closed.
– pnet
Well, I created a new question. If you can help me, any solution would be welcome!
– Érik Thiago