Unless I'm missing something (Sourceforge does odd things with formatting) then I think thats a reasonable interpretation of the snippet. I presume what you get is something like this?
<p> Text for text, <custom/>, <another/> 1>0 5<10 </p>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
HtmlCleaner cleaner = new HtmlCleaner();
CleanerProperties props = cleaner.getProperties();
props.setTreatUnknownTagsAsContent(true);
props.setNamespacesAware(false);
props.setOmitHtmlEnvelope(true);
props.setOmitXmlDeclaration(false);
TagNode node = cleaner.clean(input);
String result = new CompactHtmlSerializer(props).getAsString(node);
return result.replaceAll("<\\?xml.*\\?>", "");
As you can see, there is only one "not so good" thing here, and that is the xml tag
"<?xml version="1.0" encoding="UTF-8"?>
at the beginning of the line. I simply remove it with replaceAll. Perhaps there are configurations to prevent this tag from appearing as well, but I haven't found it)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have input some like this
But replace brackets only for "1>0 5<10" and create <custom> with close slash.</custom>
Last edit: Nazarets Danylo 2023-04-05
Unless I'm missing something (Sourceforge does odd things with formatting) then I think thats a reasonable interpretation of the snippet. I presume what you get is something like this?
<p> Text for text, <custom/>, <another/> 1>0 5<10 </p>no, I got some like this.
But, I fixed this using next code:
As you can see, there is only one "not so good" thing here, and that is the xml tag
at the beginning of the line. I simply remove it with replaceAll. Perhaps there are configurations to prevent this tag from appearing as well, but I haven't found it)
The open and close tags, rather than self-closing tags, are how HTML is typically serialised.
If you want to omit the XML tag, use
props.setOmitXmlDeclaration(true);