#53 Getting the position of an attribute within a tag

open
nobody
None
5
2007-04-23
2007-02-02
Kevin C. Dorff
No

For the parser I am creating, it is would be VERY helpful if I could easily get the character position within the entire HTML of the value of an attribute, but, this information doesn't seem to be on the Attribute object. Such as

some text<img src="x.gif" alt="other text">blah
^
With my visitor I can easily determine that I am in an IMG start tag, find the ALT attribute, and determine it has the text (other text) but I need to know that is at character 31 within the file. I am able to guess it is this position because I know that the img tag node is at position 10 and I can do an indexOf of (other text) within the text of the img node, but, of "other text" appeared earlier somewhere in the tag, I wouldn't be getting form the alt attribute.

Kevin

Discussion

  • Kevin C. Dorff
    Kevin C. Dorff
    2007-02-02

    Logged In: YES
    user_id=657555
    Originator: YES

    The "^" below the html fragment should be aligned with the "o" in "other text".

     
  • Derrick Oswald
    Derrick Oswald
    2007-04-23

    Logged In: YES
    user_id=605407
    Originator: NO

    Changing to a Request for Enhancement.

     
  • Derrick Oswald
    Derrick Oswald
    2007-04-23

    • labels: 638217 -->
    • summary: Getting the position of an attribute within a start tag --> Getting the position of an attribute within a tag