HTML String to Element

Just a quick on that’s racking my brain.

How do I take a string like below, and create an element of it.

Something like,

String element = "<div id ="itsadiv" class="divable"></div>;
Element element = Element.fromString(element);

Thankyou

Hayden

Hi Hayden. I don’t recall that we have any public API for creating an Element from an arbitrary HTML string, but you can create a new component from that with [new HTML(String outerHtml)]
(https://vaadin.com/api/platform/10.0.4/com/vaadin/flow/component/Html.html#Html-java.lang.String-). If you really need the element, you can try to retrieve it from the component (as it internally has an element anyway) or take a look at what happens with that constructor and to try create the Element in similar fashion.