使用类似Marshal的编码器处理HTML

I have several html templates that I populate using a combination of css selectors(cascadia) and manually manipulating the html Nodes (using x/html). Is there any better way to do this ? Something like the xml.Marshaller ?

I've tried using xhtml and along with the xml package(Decoder.AutoClose = H TMLAutoClose) but the issue is that on Decoding a lot of information/structure is lost (i.e. extra divs that are used for styling only and not included in the Data struct).

XSLT transform XML data with template and generates text or xhtml output. This might work for your use case https://www.w3schools.com/xml/xsl_client.asp