Java to Find Unclosed HTML Tags -
How can I get a tag in an HTML string that has no closing tag and can close it?
HTML string with a tag without tags:
& lt; Html & gt; & Lt; Top & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; P style = "margin-top: 0" & gt; Dada & lt; / P & gt; & Lt; Input size = "1" type = "text" value = "A" & gt; & Lt; / Body & gt; & Lt; / Html & gt; to
& lt; Html & gt; & Lt; Top & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; P style = "margin-top: 0" & gt; Dada & lt; / P & gt; & Lt; Input size = "1" type = "text" value = "A" & gt; & Lt; / Input & gt; & Lt; / Body & gt; & Lt; / Html & gt; Thanks!
I have two options for you (I like the second most important.)
1 Instead of parsing a well-formed or valid XML, parses as HTML because it is found in the wild: Poor, bad and cruel, though often far from the smallest tagsup is designed for people who use some of the visual effects of rational app design Area is processed at this stuff. By providing the SAX interface, it also allows the standard XML tool to be applied to the worst HTML tag soup includes a command line processor that reads HTML files and either clean HTML or well-generated XML generator Which is a close approximation of XHTML. The device we are using I have mentioned another device but is not using IM.
2 Just download the jar file and unzip it.
java -jar htmlcleaner-2.8.jar src = This will correct the missing tag and give the output - to run the jar file as below.
Example- I have an HTML file with the following content
& lt; Table & gt; & Lt; TR & gt; & Lt; Td> Incorrect table gives it out as below
c: \ user \ lasifa benaragama \ download \ htmlcleaner-2.8 & gt; Java - Jar htmlcleaner-2.8 Jar src = http: //localhost/fun/test.html April 24, 2014 12:23:10 org.htmlcleaner.audit.HtmlModificationListenerLogger FI reHtmlError information: fireHtmlError: TR April 24 on RequiredParentMissing (True) , 2014 00:23: org.htmlcleaner.audit.HtmlModificationListenerLogger FI reHtmlError information at 10 PM: fireHtmlError: UnclosedTag (right) table April 24, 2014 12:23:10 org.htmlcleaner.audit.HtmlModificationListenerLogger FI reHtmlError information on: UnclosedTag (True): fireHtmlError tbody April 24, 2014 12:23:10 org.htmlcleaner.audit.HtmlModificationListenerLogger FI reHtmlError information: fireHtmlError: TR on UnclosedTag (right) April 24, 2014 12:23:10 org.htmlcleaner.audit.HtmlModificationListenerLogger Fi reHtmlError Information you: FireHtmlError: td & lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; UnclosedTag (true) & lt; Html & gt; & Lt; Head / & gt; K & lt; body & gt; & Lt; Table & gt; & Lt; Tbody & gt; & Lt; TR & gt; & Lt; Td> Incorrect table & lt; / Td> & Lt; / Tr & gt; & Lt; / Tbody & gt; & Lt; / Table & gt; & Lt; / Body & gt; & Lt; / Html & gt; I also tested your html, output is
c: \ user \ lasifa benagama \ download \ htmlcleaner-2.8> java -jar htmlcleaner - 2.8 Jar src = http: //localhost/fun/test.html & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Html & gt; & Lt; Head / & gt; & Lt; Body & gt; & Lt; P style = "margin-top: 0" & gt; Dada & lt; / P & gt; & Lt; Input size = "1" type = "article" value = "A" /> & Lt; / Body & gt; & Lt; / Html & gt; C: \ Users \ lasifa benaragama \ download \ html kleinnikan-2.8> gt; Thanks.
Comments
Post a Comment