Hey, i'm the author of fq. It can convert to/from html and JSON (in two different modes). Use -d html, or the fromhtml, fromxml and toxml functions. Ex:
$ curl -s https://news.ycombinator.com/ | fq -r -d html 'grep_by(."@class"=="titleline").a."#text"'
Inkbase: Programmable Ink
New details on commercial spyware vendor Variston
How We Built Fly Postgres
...
$ curl -s https://news.ycombinator.com/ | fq -r -d html '{hosts: {host: [grep_by(."@class"=="titleline").a."@href" | fromurl.host]}} | toxml({indent:2})'
<hosts>
<host>www.inkandswitch.com</host>
<host>blog.google</host>
<host>fly.io</host>
...
</hosts>