The htsearch uses very old school template generation. I propose breaking the output into its two parts: data and html. htsearch should ONLY return data that can be consumed by other services (such as a template engine to generate html). I have hacked htdig to output XML but it still has deficiencies. Specifically, passing of parameters to htsearch is prone to error and difficult when url and shell encoding are needed for handling special chars. I'll attach the changes I have made but the engine itself needs rewriting. Perhaps a program htxml that takes all available arguments individually and returns xml output is warranted?
We feed the xml output into other apps so that they can consume the search data. Each app has it's own output and cannot use the htsearch html output.