From: "henryturnerlists@..." Date: 2008-10-07T16:58:20+09:00 Subject: Re: Hpricot elem index/position Hi Mark, I'm writing a broken link reporting type tool. When I find a dodgy tag I'd like to be able to relay the character position and or line number to the user. Useful for debugging. Thanks -h On Oct 6, 9:13 pm, Mark Thomas wrote: > On Oct 6, 10:19 am, "henryturnerli...@googlemail.com" > > > > wrote: > > Hey, > > > Trying to find the String index of an Hpricot::Elem within its doc. > > For example.. > > > doc = Hpricot("bobjamesdan") > > elem = doc.search("a")[1] > > elem.start #=> 10 ( the first '<' of the second a tag.) > > > and eventually the following would be good.. > > > elem.length #=> 12 > > elem.end #=> 21 > > > Any thoughts appreciated! > > Henners > > My first thought is: Why do you want that information? Character > position is meaningless in an XML and HTML DOM. Whitespace can change > character positions without affecting the DOM at all. > > -- Mark.