-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Element factory method #1411
Comments
Hi -- this makes sense and I think is a good idea. One issue with them being static methods (Element.of or Jsoup.parseElement) is that HTML parse settings cannot be applied or inherited from the current doc. Maybe we can have it like Maybe both that and |
To be consistent with Jsoup.parse, we may want a function named |
@jhy would you help review my pr? Appreciate! |
@xiaoxianma thanks - please see my comments on #1521. Similar thoughts on this. |
This is a feature request for a more concise way of creating Elements objects directly from an HTML String. Right now, especially in unit tests, we have lots of code that looks like this:
Element e = new Element("div").html("<span>Some stuff</span><span>Second part</span>");
It would be very nice to have something more like this:
Element e = Element.of("<div><span>Some stuff</span><span>Second part</span></div>")
Or alternatively have a parser method like
Element e = JSoup.parseElement("<div></div>");
This is not only more concise, it would allow easier dynamic creation of mock elements for testing from a data file or list of HTML strings.
The text was updated successfully, but these errors were encountered: