adhanlon
adhanlon

Reputation: 6539

Are there any tools for parsing HTML using GWT

in my GWT application, on the client side I have a string containing html. Is there a good way to go about parsing that and finding specific html tags within it and returning the id's of those tags?

Any help would be much appreciated, thanks!

Upvotes: 1

Views: 3101

Answers (2)

z00bs
z00bs

Reputation: 7498

Check out GWT query. It is a jQuery like API for GWT that allows easily traversing and manipulating HTML.

Upvotes: 3

Christoph Dietze
Christoph Dietze

Reputation: 902

You could attach your HTML string to the DOM - using Element.setInnerHTML(yourString). That way you're using the browser's parser. Attaching it to an invisible element or an invisible iframe should hide whats happening from the user.

For the querying you can use GWT's DOM functions if you want to stick with plain GWT. Using JavaScript directly or any JavaScript library like jQuery are also options. GWT query might also be an option, but I haven't used that yet.

UPDATE: This approach can be abused by XSS (cross site scripting) attacks - so you must either trust or sanitize the HTML string.

Upvotes: 2

Related Questions