1
I have this code pad:
xml = xml.Replace("<html>", "");
xml = xml.Replace("<head>", "");
xml = xml.Replace("</head>", "");
xml = xml.Replace("<body>", "<certidoes>");
xml = xml.Replace("</body>", "");
xml = xml.Replace("</html>", "</certidoes>");
My question is: Is there any way to abstract this block in a way that is more friendly and simple ?
I need you to remove html tags and tag certificates.
Note: xml = is an xml I have in the content of the HTML page
Dude, your solution worked well, but the <certidoes> tag is not in the HTML file, so I put it in replace. Within this your solution, is there any way to put it? And it would be possible to put a brief explanation of what is happening ?
– Érik Thiago
What do you mean put it? You want to insert the <certidoes> tag into an HTML and then remove the HTML. Can you explain to me the whole process you are doing? So we can try to come up with a simpler solution.
– Andrew Paes
Well, what I do is take a string even if it’s multiline ( @ lets you write multilines ), so I simulate that you opened a file and passed it all to a string. Then I take this string and replace the <body> tags to find it easier. Then I remove everything before "|" and after "#". Resulting only the <certidoes> tag and what is inside it.
– Andrew Paes
Andrew I’ll explain, I hope to be clear.. kkk. What happens is that in order for me to be able to read my xml, I need to have a root tag. This root tag is the certificates. But when I download the HTML file the tag
<certidoes>
is not in the document, so what do I do ? I give a replace that way:xml = xml.Replace("<body>", "<certidoes>")
. So I remove the HTML tag<body>
and tag<certidoes>
in place. And likewise it happens in this line:xml = xml.Replace("</html>", "</certidoes>")
. I think I can explain!– Érik Thiago
Simple guy! This helps a lot! But I hope I was clear in the other comment!
– Érik Thiago
And inside the <body> tag you have an XML, right? So then why do you need to create this <certidoes> tag instead of simply taking the html and leaving the XML tags that are already there, and with this feed XML in C# a collection that will be the certificates?
– Andrew Paes
But if you want I edit the answer to include the <certidoes tag>
– Andrew Paes
Because in the logic of scanning xml, at the time of reading, when the reader arrives at the <certidao> tag he ignores it and cannot read the xml. So I need a root tag so that it ignores it, that is, the <certidoes tag> and read everything that is in the <certidao tag>.
– Érik Thiago
I’d like to, man, if I could, it would be really good!
– Érik Thiago
IT WORKED MAN! IT WAS WORTH TOO !
– Érik Thiago