File: 26predicate.t

package info (click to toggle)
libxml-xpath-perl 1.48-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 608 kB
  • sloc: perl: 4,444; xml: 34; makefile: 10
file content (26 lines) | stat: -rw-r--r-- 362 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use Test;
BEGIN { plan tests => 4 }

use XML::XPath;
ok(1);

my $xp = XML::XPath->new(ioref => *DATA);
ok($xp);

my @bbb = $xp->findnodes('//a/b[2]');
ok(@bbb, 2);

@bbb = $xp->findnodes('(//a/b)[2]');
ok(@bbb, 1);

__DATA__
<xml>
    <a>
        <b>some 1</b>
        <b>value 1</b>
    </a>
    <a>
        <b>some 2</b>
        <b>value 2</b>
    </a>
</xml>