I'm having some trouble adding a new tag to my Document. For example I have:
Document doc = Jsoup.parse(htmlString);
Element table = doc.select("table").first();
Now If I want to add a <LINK>
tag with attributes (href,type,rel) to my table element, and then return the total as a string, How would I do this?
Using the innerHTML attribute:To append using the innerHTML attribute, first select the element (div) where you want to append the code. Then, add the code enclosed as strings using the += operator on innerHTML.
With XPath expressions it is able to select the elements within the HTML using Jsoup as HTML parser.
Use something like this:
Jsoup.parse(new URL(""), 0).getElementById("test").appendElement("h1").attr("id", "header").text("Welcome");
And all ".append*" methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With