Thursday, March 25, 2010

Using HTMLCleaner in Java to convert your pages to DOM and then back again, but finding the pages come up blank in a brower?


private void fixScriptTagWierdness(TagNode document) {
//name says it all - symptom is a blank page in Firefox and IE, works fine in Chrome. Silly browsers require that " and doesn't have (valid?) ..../> ending.
//hence we stick some junk inside the element and it expands it and everything workie.
TagNode scriptTag=document.findElementByName("script", true);
if (scriptTag!=null)
{
scriptTag.addChild(new TagNode("junk"));
}
}