From: Paul Lutus Date: 2006-12-18T04:35:10+09:00 Subject: Re: hpricot problem Peter Szinek wrote: / ... > Btw. ever heard of 'reinventing the wheel'? I don't generally reinvent the wheel until the existing wheel breaks. This is one of those cases. > Also your (otherwise great) code snippets always assume that the > underlying HTML is well formed, and x and y and z - which is in real > life almost never the case. Yes, true, my code is typically quite fragile and can only handle essentially perfect HTML, and I generally offer that exact warning. Ironically, though, in this case, my naive solution parsed the HTML that caused Hpricot to fail. > Of course the posters here are not pasting > 200K of HTML against which they run they production code, but a few > lines of example which is usually an oversimplification of the problem. Almost always. But in this case Hpricot failed on the provided short example, with a single deviant tag syntax. > This another point where such libraries are great: they handle 844747 > special cases (if your case is not among them, see the current-2nd > paragraph, or add it there on your own) which is always a problematic > thing in case of hand written stuff. Absolutely. I don't generally post my offer of a few lines of code unless and until a library has failed. In this case, it failed. > I could state here 100 another points which would prove that in > production, libraries are almost always better choice over hand written > code on the fly - Yes, unfortunately none of them would successfully answer this OP's call from the real world. Libraries are the obvious solution to this kind of task. They have everything going for them, up to, but not including, the moment when they fail to meet the user's requirements. I have to say that I see a lot of posts that follow this pattern. The library seems to be able to solve any number of difficult problems except the specific problem the user happens to be facing. And my typical offered, simple solution is not meant to, and cannot stand in for, the 2^32 special cases that have been laboriously programmed into the library. It can only provide an overlooked special need that the library cannot provide. It's surprising to me how often this happens. -- Paul Lutus http://www.arachnoid.com