Menu

Read comment and script from source

2010-08-24
2013-01-03
  • Michael Schwartz

    Hi,

    I want to read the comment-content from source but do not find a working solution.
    Neither TextExtractor nor subsequence returns the content of this attribute.

    To state an example: Source contains e.g. <style type="text/css"> <!- someStyleIWantToExtract -></style>
    while I currently get <style type="text/css"><!- -></style>
    and I am not able to access the "someStyleIWantToExtract " content via the Element-class. Any hints how to accomplish this?

    Thanks a lot.

     
  • Martin Jericho

    Martin Jericho - 2010-10-11

    A comment is considered to be one big start tag rather than an element with separate start tag, content and end tag.  To get the content of a comment, you need to use the StartTag.getTagContent() method.

    Regards, 
    Martin

     
  • Michael Schwartz

    Thanks, Martin. This is exactly what I needed.

     

Log in to post a comment.