문제

I'm cleaning HTML using cyberneko and xerces. However , some $#@@!@@ websites still use BOTH

<script>...</script> and <script.../> 

So what happens is this : given

<script..../> <div> Some Text </div> <script> scripting stuff </script> , 

neko parses all the above line as a script , so I get

<script..../> &lt div &gt Some Text &lt/div &gt &lt script &gt scripting stuff </script> , 

And then I lose all the inside content :(

Any advice?

도움이 되었습니까?

해결책

Using <script /> is illegal in html. It is legal in xml. I don't know why some people still use the xml way to write html, but it's wrong, and it breaks most of the parsers (like SO..) - by design.

Another thing to notice - if you use xml parsers / dom4j parsers or any other thing that depends on it , make sure you're not passing your string through an xml parser and then an html parser - this will break everything.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top