0

The snip of code below comes from a very large document with all types of tags. I can extract and change things to what I want including working with checkboxes. What I can't seem to do is change and add styles to anything. It does pickup any styles found in the style tags originally submitted. When I go through the elements I can replace the button value with the word "Service" as shown below but I cannot change the font to 10pts or change the color. For the textbox listed in the HTML code I cannot change the vertical alignment to top. I guess I really just can't seem to change the styles from what was assigned originally or add a style if it does not exist. I tried to post the original HTML code but it did not appear correct on here... Please help if you can... I just need the JSoup way to add or replace a style on a single tag as shown below ... Thanks...

        for(Element element : elements){
            sFieldName = element.attr("name");
            if (element.attr("name").equals("scode")) {
                element.replaceWith(new TextNode("Service", sFieldName));
            }

}

  • I'm not sure what you're trying to do from your description. A TextNode is the text in an element (tag); it can't have style attributes so your code snippet can't do anything. Can you just post the HTML you have and the HTML you want? – Jonathan Hedley Jun 17 '17 at 15:20
  • Thanks for responding... and yes the example does look pretty bad. I was trying to replace an html button that had the value attribute set to the word "Service" and make it TextNode without the borders using CSS. What worked for me was the following: – Bigfoot002 Jun 18 '17 at 17:26

0 Answers0