Monday, 15 February 2010

How to do HTML to XML conversion to generate closed tags? -



How to do HTML to XML conversion to generate closed tags? -

how xml html conversion generate closed tags.

the context explained here: error while generating pdf html file in java using itext

when seek converting html pdf using itext , xml worker, i'm asked give closing tag <hr> , <br> tags. works if manually: conversion pdf worked! don't want add together each closing tag manually. how can in automated way?

you experiencing problem because feeding html itext's xml worker. xml worker requires xml, need convert html xhtml.

there illustration on how on official itext site: d00_xhtml

public static void tidyup(string path) throws ioexception { file html = new file(path); byte[] xhtml = jsoup.parse(html, "us-ascii").html().getbytes(); file dir = new file("results/xml"); dir.mkdirs(); fileoutputstream fos = new fileoutputstream(new file(dir, html.getname())); fos.write(xhtml); fos.close(); }

in example, path ordinary html file (similar have). utilize jsoup library parse html xhtml byte array. in example, utilize byte array write xhtml file disk. can utilize byte array straight input xml worker.

html xml itext

No comments:

Post a Comment