HtmlArea data as XML or JSON

Currently in Enonic XP, any HTML data entered into a content-type input field of type HtmlArea will always be sent to the view as a string, even though it contains valid XML. I’m assuming this is because the indexable field needs to be a single string for fulltext search to be practical.

But: If any sort of markup changes are desired (such as add some attributes required for responsive image handling), the process gets complicated if you need to do more changes to the data than what can be solved with some simple regexp matching. I would have thought that Enonic XP’s lib-xslt could do the trick, but since the HtmlArea data is sent to the view as a simple string and not XML, you can’t process the data in any other way than simply unescaping the tags. Thus, the XSLT template matching won’t apply on your data, which makes the whole point of using XSLT moot.

In other words, I’d love to see that HtmlArea data was sent to lib-xslt as XML so it could be manipulated. But wouldn’t it be even more awesome if Enonic XP had some built-in library that provided this data as JSON? Yes, I’m aware that there is no perfect implementation of XML<=> JSON mapping. But I think it deserves a discussion here.


Related info: Some suggestions on how to parse XML in Enonic XP have been provided in this discussion:

We have added an XML lib to the backlog. This will resolve these issues.