in reply to HTML::TreeBuilder:: identifing xpath-expression - first attempt
XPath is a W3C Recommendation. The documentation from that link will help you understand what XPather is outputting.
I looked at the source for the link (http://www.educa.ch/dyn/79376.asp?id=1187) you provided. All of the data that you are collecting appears to be in <div class="leerzeile"> elements.
It's generally better to target something like that than use hard-coded indices (e.g. div[3], div[4], etc.): if the site owner's decide to add some additional comment at the top of the page, what's in the 3rd <div> today may be in the 4th tomorrow; addresses won't necessarily have the same number of lines so perhaps you only want up to the 12th <div> or could need the 14th <div> as well.
Following the XPath link above, you'll see a large number of examples under Location Paths. One in particular stands out as close to what you want:
child::para[attribute::type="warning"] selects all para children of the context node that have a type attribute with value warning
So, you can probably get all the data you need by accessing div[attribute:class="leerzeile"] instead of a long list of div[N] paths. I didn't study the markup in minute detail: if that doesn't get everything you want, I'd still use that type of technique rather than opting for a hard-coded index.
Finally, just a note on the markup in your question: links are created with [url] and named links with [url|name] - this and related information are explained in Writeup Formatting Tips.
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: HTML::TreeBuilder:: identifing xpath-expression - first attempt
by viveksnv (Sexton) on Oct 17, 2010 at 08:36 UTC | |
by Anonymous Monk on Oct 17, 2010 at 09:20 UTC | |
by Khen1950fx (Canon) on Oct 17, 2010 at 23:17 UTC | |
by Perlbeginner1 (Scribe) on Oct 19, 2010 at 15:54 UTC | |
|
Re^2: HTML::TreeBuilder:: identifing xpath-expression - first attempt
by Anonymous Monk on Oct 17, 2010 at 09:18 UTC |