<?xml version="1.0" encoding="windows-1252"?>
<node id="979111" title="Re^2: Help with xpath and TreeBuilder" created="2012-06-29 08:09:27" updated="2012-06-29 08:09:27">
<type id="11">
note</type>
<author id="961">
Anonymous Monk</author>
<data>
<field name="doctext">
&lt;p&gt; Its even easier :)
&lt;c&gt;
my @xpaths = qw{
/html/body/p/a
/html/body/p[2]/a 
/html/body/p[3]/a
....
/html/body/p[66]/a
};
my $allXpaths = join ' | ', @xpaths;
my @values = $tree-&gt;findvalues;
&lt;/c&gt;
&lt;p&gt; I don't know about &lt;b&gt;other&lt;/b&gt; xpath interpreters, but treebuilder::xpath (and [href://http://xsh.sf.net|xsh] ) allows this
&lt;p&gt; This query is probably faster
&lt;c&gt;
/html/body/p[
position()=1
or  position()=2
or  position()=3
or  position()=66
]/a
&lt;/c&gt;
&lt;p&gt; Or this one &lt;c&gt;
/html/body/p[
(
  (
    position() &gt; 0
    and position() &lt; 4
  )
  or
  (
    position()=66
  )
)
]/a
&lt;/c&gt;
&lt;p&gt; Though this one won't work with your html &lt;c&gt; //a[ position()=4] &lt;/c&gt; because each //a is at &lt;c&gt; //a[ position() = 1] &lt;/c&gt; because each //a is the only (first) child of its parent ( p ) &lt;B&gt;---&lt;/B&gt; I guess now I know how position() works</field>
<field name="root_node">
979047</field>
<field name="parent_node">
979098</field>
<field name="reputation">
4</field>
</data>
</node>
