Menu

Replacing attribute on a tag

hatu fr
2009-10-11
2013-01-03
  • hatu fr

    hatu fr - 2009-10-11

    Hi,

    I was working with OutputDocument (the helper to modify the HTML content) I noticed that there is no way to replace easly the value of an attribute or the attribute itself.

    I used the standard method String.replace("pattern","newValue")

    With a segment or a element, you can use the position (getBegin() or End) but there is not such of mechanism for attributes.

    Did i miss something?

    Cheers.

     
  • Martin Jericho

    Martin Jericho - 2009-10-11

    The Attribute class also extends Segment, so has getBegin() and getEnd() methods.  It also has a getValueSegment() method to get the begin and end positions of the value.

     
  • Martin Jericho

    Martin Jericho - 2009-10-11

    The documentation of the Attributes class also mentions a way of adding or deleting attributes.

     

Log in to post a comment.