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


In reply to Re: HTML::TreeBuilder:: identifing xpath-expression - first attempt by kcott
in thread HTML::TreeBuilder:: identifing xpath-expression - first attempt by Perlbeginner1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.